rethinkdb / horizon

Horizon is a realtime, open-source backend for JavaScript apps.
MIT License
6.78k stars 351 forks source link

Running `hz` command by itself #328

Open w3irdrobot opened 8 years ago

w3irdrobot commented 8 years ago

Many of the CLIs I use will print the help documentation when it is run with -h but also when it is run by itself. I'd like to implement this functionality. So if you run hz, it will print out the same help text as hz -h.

I'm currently working with:

CLI version: 0.3.1 Client version: 0.1.0 Server version: 0.1.1-0

deontologician commented 8 years ago

I think right now this functionality is provided directly by the argParse library we use. It's possible it's an option you can customize. If it isn't an option though, I'd rather just accept this small difference over rolling our own command line parser (refactoring to another parser would be a pain, I'm not convinced this would be worth it)

SamMauldin commented 8 years ago

I looked at the documentation for argparse and didn't see any options for help on no arguments. The .parse method throws an error that we could catch. Someone with more experience with argparse might be able to do it in a more elegant way.

w3irdrobot commented 8 years ago

If you look at the source for argparser, there is a method on it called printHelp that I think will do the job. Super easy. More of a UX thing for the CLI. Not needed. More of a simple enhancement.

SamMauldin commented 8 years ago

Yes, but capturing a no arguments event is the hard part.

w3irdrobot commented 8 years ago

In the CLI's main.js, at the bottom, we could add a default case that runs the help text.

SamMauldin commented 8 years ago

This doesn't work because parser.parse throws an error and exits when something isn't matched. Could we add a parser that catches no arguments?

bopjesvla commented 8 years ago

hz should probably display the help page (or help on how to display the help page) outside hz projects, but coming from Meteor, I expect it to act as a shorthand for hz serve or hz serve --dev otherwise.

refactoring to another parser would be a pain, I'm not convinced this would be worth it

Maybe I'm missing something, but refactoring to yargs should be pretty easy. The additional functionality, elimination of boilerplate code, and better formatting of help pages are definitely worth it. I wouldn't mind putting together a PR.

deontologician commented 8 years ago

ping @Tryneus @dalanmiller for opinions

bopjesvla commented 8 years ago

hz should probably display the help page (or help on how to display the help page) outside hz projects, but coming from Meteor, I expect it to act as a shorthand for hz serve or hz serve --dev otherwise.

Alternatively, allow folks to set their own default command in config.toml. This would typically be a folder watcher that builds and serves on changes.