Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting 404 errors every time on cht.exe, same command works using curl #7

Open
jbrown123 opened this issue Nov 21, 2022 · 16 comments
Open

Comments

@jbrown123
Copy link

I have the latest cht.exe (just downloaded moments ago) in my path. No matter what I request or how I request it I always get a 404 error.

When I uses cht c/strlen I get the following:

c:\>cht c/strlen
/*
 * 404 NOT FOUND
 *
 * Unknown cheat sheet. Please try to reformulate your query.
 * Query format:
 */

 /LANG/QUESTION

/* Examples: */

 /python/read+json
 /golang/run+external+program
 /js/regex+search

/*
 * See /:help for more info.
 *
 * If the problem persists, file a GitHub issue at
 * github.com/chubin/cheat.sh or ping @igor_chubin
 */

Asking with space instead of a slash also doesn't work.

c:\>cht c strlen
/*
 * 404 NOT FOUND
 *
 * Unknown cheat sheet. Please try to reformulate your query.
 * Query format:
 */

 /LANG/QUESTION

/* Examples: */

 /python/read+json
 /golang/run+external+program
 /js/regex+search

/*
 * See /:help for more info.
 *
 * If the problem persists, file a GitHub issue at
 * github.com/chubin/cheat.sh or ping @igor_chubin
 */

Same if I just ask for a unix command like shutdown:

c:\>cht shutdown
/*
 * 404 NOT FOUND
 *
 * Unknown cheat sheet. Please try to reformulate your query.
 * Query format:
 */

 /LANG/QUESTION

/* Examples: */

 /python/read+json
 /golang/run+external+program
 /js/regex+search

/*
 * See /:help for more info.
 *
 * If the problem persists, file a GitHub issue at
 * github.com/chubin/cheat.sh or ping @igor_chubin
 */

However, if I use curl for the same queries, it works fine:

c:\>curl cht.sh/shutdown
 cheat:shutdown
# To reboot the system immediately:
shutdown -r now

# To shut system down immediately:
shutdown -h now

# To reboot system after 5 minutes:
shutdown -r +5

# To cancel a scheduled shutdown:
shutdown -c

 tldr:shutdown
# shutdown
# Shutdown and reboot the system.
# More information: <https://manned.org/shutdown.8>.

# Power off (halt) immediately:
shutdown -h now

# Reboot immediately:
shutdown -r now

# Reboot in 5 minutes:
shutdown -r +5 &

# Shutdown at 1:00 pm (Uses 24h clock):
shutdown -h 13:00

# Cancel a pending shutdown/reboot operation:
shutdown -c

or by language

c:\>curl cht.sh/c/strlen
/*
 * If you want to rewrite standard C function `strlen` then you should
 * follow [the declaration
 * conventions](http:www.iso-9899.info/n1570.html#7.24.6.3) of the
 * function.
 *
 * >     size_t strlen(const char *s);
 *
 * First of all it should have return type `size_t` and the parameter
 * shall have qualifier `const` that you could use the function with
 * constant character arrays.
 * Also such a name as `sum` is not very suitable for this function. In
 * your function you have too many local variables.
 *
 * I would write the function the following way
 */

 size_t strlen( const char *s )
 {
     size_t n = 0;

     while ( s[n] ) ++n;

     return n;
 }

/* The other way is to use only pointers. For example */

 size_t strlen( const char *s )
 {
     const char *p = s;

     while ( *p ) ++p;

     return p - s;
 }

/* [Vlad from Moscow] [so/q/26923117] [cc by-sa 3.0] */
@jbrown123
Copy link
Author

Updated to add - looking in wireshark I see the following:

cht shutdown -> GET /shutdown// (note the two trailing slashes) which produces a 404 error as shown above.

On the other hand ...
cht -Q shutdown -> GET /shutdown which produces the correct results:

c:\>cht -Q shutdown
 cheat:shutdown
# To reboot the system immediately:
shutdown -r now

# To shut system down immediately:
shutdown -h now

# To reboot system after 5 minutes:
shutdown -r +5

# To cancel a scheduled shutdown:
shutdown -c

 tldr:shutdown
# shutdown
# Shutdown and reboot the system.
# More information: <https://manned.org/shutdown.8>.

# Power off (halt) immediately:
shutdown -h now

# Reboot immediately:
shutdown -r now

# Reboot in 5 minutes:
shutdown -r +5 &

# Shutdown at 1:00 pm (Uses 24h clock):
shutdown -h 13:00

# Cancel a pending shutdown/reboot operation:
shutdown -c

@cobrabr
Copy link

cobrabr commented Nov 22, 2022

Same exact problem for me.

@liudonghua123
Copy link

I have the same problems.

Is this project deprecated or died?

@tpanj
Copy link
Owner

tpanj commented Nov 24, 2022

Thanks all for reporting and voicing up. Project is not dead. Just little inactive due lack of time. Need also to rethink this clumsy -Q option and correct right. Any ideas?

Is it also true I am thinking about rewriting to vlang.

@liudonghua123
Copy link

I do not familiar with vlang. I use python, js, java a lot.

How about using flutter or tauri to rewrite, both two are lightweight, beautiful ui, easy customization, popular and platform independent framework to build app.

@tpanj
Copy link
Owner

tpanj commented Nov 24, 2022

@liudonghua123 AFIK flutter or tauri are more for GUI defelopment, tauri is better as electron alternative and with this we lost support for oldest computers console (it is Win7+). How important is this for you to have it backward compatible with XP+?

@liudonghua123
Copy link

Yes, the flutter and tauri are both cross platform GUI framework, not for console app development. The minimum os requirements for windows is win7. I forget this app is a console app 😄

@liudonghua123
Copy link

For console app, I would like to use some platform independent program language like python, node, dart...
Dart is a mordern language which could produce small sized aot executables for windows, linux and macos.

@robbely
Copy link

robbely commented Mar 27, 2024

This is still a problem a year and a half later, so I guess this has now been abandoned :(
(Also with the -Q option - this sometimes works, sometimes crashes)

@tpanj
Copy link
Owner

tpanj commented Mar 28, 2024

Thanks for your interest and feedbacks. I am working on porting complete source code and make it more maintainable and portable vlang - I decided basically by #10 . Stay tuned since I will finish publish it in approximately month.

@tpanj
Copy link
Owner

tpanj commented Apr 1, 2024

I have the latest cht.exe (just downloaded moments ago) in my path. No matter what I request or how I request it I always get a 404 error.

When I uses cht c/strlen I get the following:

c:\>cht c/strlen
/*
 * 404 NOT FOUND

Should work now and get the same result as curl cht.sh/c/strlen

c:\>cht c strlen

This should be now applied with "domain language" option -l so full command for this is:

cht -l c strlen

Believe that the next versions can be more error tolerant, but for now this is it.
I would be very happy receiving feedback (so can I close issue), test cases or more usage examples.

@robbely
Copy link

robbely commented Apr 1, 2024

Many thanks - new version is working well for me (tested basic cht xxxx where xxx is anything I would expect in cheat.sh).

I do get an odd error "V panic: array.get: index out of range (i == 0, a.len == 0)" when i use cht with something not in the database so maybe it needs to catch this error, (but it's a trivial issue as it still does what it should).

@Gaweringo
Copy link

The scoop version is still at 0.6. Should I update the manifest to 0.7.1 and add autoupdate?

@tpanj
Copy link
Owner

tpanj commented Apr 2, 2024

The scoop version is still at 0.6. Should I update the manifest to 0.7.1 and add autoupdate?

Great but hold on - new version is coming.
Do you think it would be better to have "_v0.7.2.zip" at end of assets for autoupdatesand so or should I leave like it is?

@Gaweringo
Copy link

Gaweringo commented Apr 2, 2024

Do you think it would be better to have "_v0.7.2.zip" at end of assets for autoupdatesand so or should I leave like it is?

Whichever you like more, for the scoop auto-updater it doesn't matter, since it gets the version from the release feed.

    "autoupdate": {
        "architecture": {
            "64bit": {
                "url": "https://github.com/tpanj/cht.exe/releases/download/v$version/cht_windows.zip"
            }
        }
    }

new version is coming.

Well, with auto-update set up correctly that shouldn't be a problem, as long as the file name does not change.
If you want to change the name of the zip, I'll wait.

@tpanj
Copy link
Owner

tpanj commented Apr 3, 2024

Great. Pushed new version and leave zips like they are.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants