kettle11 / devserver

A simple HTTPS server for local development. Implemented in Rust.
zlib License
95 stars 15 forks source link

Unrecognized flag: `"/home/dh/.cargo/bin/devserver"`. See available options with `devserver --help` #9

Closed d4h0 closed 4 years ago

d4h0 commented 4 years ago

Hi,

cargo install devserver installs devserver to '~/.cargo/bin/devserver' (on Linux).

Executing '~/.cargo/bin/devserver', however, failes with the above error.

If you change the line let args: Vec<String> = env::args().collect(); to let args: Vec<String> = env::args().skip(1).collect(); and remove the match arm "devserver" => {} it should work as expected.

However, I think you should just use a command line argument parser instead.

By the way, I read most of the code, and I'm wondering why you didn't use crates for most of the stuff?

You wrote somewhere that you want to keep devserver simple, but I think this approach makes it much more complex and error-prone.

For example, for WebSockets there is the fantastic tungstenite, for the argument parse I'd use strucktopt (probably overkill, but there are smaller crates), for the HTTP server tiny_http looks great, and for MIME types there is mime_guess.

The code probably would be 1/5th, if you would use these crates.

d4h0 commented 4 years ago

I have added '~/.cargo/bin/' to my PATH environment variable, and everything is working now, but I still think the above is a problem.

kettle11 commented 4 years ago

If you change the line let args: Vec = env::args().collect(); to let args: Vec = env::args().skip(1).collect(); and remove the match arm "devserver" => {} it should work as expected.

Good catch! I'll add that exact change today. Thanks! :)

By the way, I read most of the code, and I'm wondering why you didn't use crates for most of the stuff?

You wrote somewhere that you want to keep devserver simple, but I think this approach makes it much more complex and error-prone.

For example, for WebSockets there is the fantastic tungstenite, for the argument parse I'd use strucktopt (probably overkill, but there are smaller crates), for the HTTP server tiny_http looks great, and for MIME types there is mime_guess.

It's a valid concern and I think it would be reasonable for a tool similar to devserver to use existing crates.

The reason I didn't use other crates is because I wanted to keep the install times very low, and for the narrow case of a development only server most of the features of existing crates aren't needed.

I wanted the experience of devserver to be as straightforward as possible. It's nice to be able to install in ~23 seconds with almost no waiting around. With the dependencies you recommend that time would be ~1 minute 52 seconds which is too long.

Another reason for keeping build times low is that initally I wanted to embed devserver_lib as part of a tool for Wasm game development and I wanted to also keep the total build times for that tool very low.

Even though devserver_lib uses its own implementations my hope is also that by doing extremely few things it can still be mostly bug free. If that turns out to not be true, and lots of little issues come up forever, I'd be inclined to make a new version with existing more stable crates.

Worth noting: of the dependencies you recommended structopt is the heaviest and without it the total build time is 55 seconds, which is much better. As I said I'd be open to rewriting with existing better crates if too many bugs come up with the current approach.

Thanks for raising these points!

kettle11 commented 4 years ago

I checked in the fix for the bug you found: https://github.com/kettle11/devserver/commit/ef34eda9d2dfcf29f02fc61710df0ef2906ab041

Thanks again for reporting it!

d4h0 commented 4 years ago

Okay, that makes sense.

It seems, most of the time only the initial installation takes long, and later builds only take a few seconds, so personally I don't care much about a long first installation process.

Anyway, so far devserver work great, so I guess you are right :)

I checked in the fix for the bug you found: ef34eda

Awesome! :)