PostgREST / postgrest

REST API for any Postgres database
https://postgrest.org
MIT License
23.45k stars 1.03k forks source link

Usage message on error gives no hint about what's wrong #130

Closed randomcamel closed 9 years ago

randomcamel commented 9 years ago

I'm giving postgrest what look like reasonable options, but it won't start and gives me no hints about why.

> postgrest-0.2.5.1 --db-name mydb_dev --db-user mydbuser --db-pass mypassword --db-host localhost --port 8082 --db-port 5432 --db-pool 100
Usage: postgrest (-d|--db-name ARG) [-P|--db-port ARG] (-U|--db-user ARG)
                 [--db-pass ARG] [-h|--db-host ARG] [-p|--port ARG]
                 (-a|--anonymous ARG) [-s|--secure] [--db-pool ARG]
  create a REST API to an existing Postgres database

Do the options need to be in a specific order? Does one of them have an invalid value? I tried using the long options just in case, and adding --db-pool and --db-port even when I'm fine with defaults.

I don't know what my particular problem might be, but the app could give me some help. For extra confusion, sometimes it prints the vertical explanation of each option, and sometimes it doesn't.

[EDIT: Looks like --anonymous is required.]

adambaker commented 9 years ago

I'll make improving the error messages my first priority next time I have some time to work on this, if someone else hasn't done so already. Thanks for filing this issue.

You are correct -a|--anonymous is required. It is the role the server uses for unauthenticated requests.

begriffs commented 9 years ago

@randomcamel good point about the options being confusing. I guess I've gotten kind of used to them during development but looking at it fresh there are things to improve.

  1. Like you said, it could provide more information about required args that are missing.
  2. The options could simply be named better. For instance --anonymous looks at first sight like a boolean flag similar to --secure.
  3. The usage screen could have more details. In fact it does add more info if you specify --help but nowhere does it tell you you can do that.

It appears that number one would require us to ditch our option parser optparse-applicative because it doesn't support customized messages about missing arguments. (There is a tantalizing function in the library but I experimented with it and found it only prints errors for arguments which are provided-and-blank, not those which are omitted.)

Number two is something we should absolutely do. It will be a backwards incompatible change so let's put some thought into the best names to use so we don't have to change it again. (Among other things my buildpack to deploy postgres on heroku relies on the command line arguments being what they are and will have to change too.)

As for three, I'd like the help screen to always show the extra details, not wait until --help gets specified. There's a function for this too but I must not be using it right.

@adambaker I'd love your help if you get some time to look into this.

randomcamel commented 9 years ago

My report was a little crabby, and I want to say it's a cool tool that seems to work well once it's running. :smile:

begriffs commented 9 years ago

I was forced to revert the commits that fixed this issue due to some troublesome dependencies. I'm reopening this issue and will investigate how to fix the functionality without introducing any new dependencies.

begriffs commented 9 years ago

There has been some improvement to this issue. The program now shows full usage instructions for any error. It doesn't yet say what specifically went wrong, but does present a clearer overview.

jfischoff commented 9 years ago

I ran into this issue too. I think a stop gap is just specifying in the help what is required. Additionally the documentation on the README for the project does not include the -a option.

begriffs commented 9 years ago

The usage instructions have improved since February when this issue was created. I'm going to close this original issue and we can open future issues with specific usability suggestions as they arise.

begriffs commented 8 years ago

Added docs for the new command line arguments here: http://postgrest.com/install/server/#running-the-server