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

Question: How to show all comands flags, arguments and options help once? #6

Open
xspager opened this issue Mar 2, 2016 · 4 comments

Comments

@xspager
Copy link

xspager commented Mar 2, 2016

I want to show a full help with all options, flags... Is this supported, if not is there a recommended way to do that?

Really nice lib btw :)

@xspager xspager changed the title Question: How to show all comands flags, arguments and options once? Question: How to show all comands flags, arguments and options help once? Mar 2, 2016
@mpeterv
Copy link
Owner

mpeterv commented Mar 3, 2016

You mean you want script.lua -h to show not only top-level arguments, options and commands, but also arguments and options specific to these commands? That's currently not supported as this approach doesn't work well once there are a lot of command-specific options. You can get help for each specific command by using script.lua <command> --help.

You can sort of do it by running cmd:help(cmd:get_help()); cmd:description(cmd:get_help().."\n") for each command after it is registered. That sets description of each command to it's full help message. It won't look too good - lines get too long because of double padding:

Usage: sailor [-h] <command> ...

Sailor commands

Options:
   -h, --help            Show this help message and exit.

Commands:
   c, create             Usage: sailor create NAME [PATH]

                         Generates web application in a directory.

                         Arguments:
                            name                  The name of your application.
                            path                  The path to where you wish your app to be created. (default: .)

                         Options:
                            -h, --help            Show this help message and exit.

                         Example:  sailor create 'Hey Arnold' /var/www 
                         This will create your web app under /var/www/hey_arnold.

   t, test               Usage: sailor test [--resty] -- [EXTRA_FLAGS]

                         Will run the tests specified for an application. Must be called from the base dir of the application.

                         Arguments:
                            EXTRA_FLAGS

                         Options:
                            --resty               Run the tests using the resty bootstrap
                            -h, --help            Show this help message and exit.

   e, enable             Usage: sailor enable NAME

                         Will install an extension to Sailor and copy necessary files to your app. Must be called from the base dir of the application.

                         Arguments:
                            name                  The name of the extension to be enabled.

                         Options:
                            -h, --help            Show this help message and exit.

@xspager
Copy link
Author

xspager commented Mar 6, 2016

Decided to show only the commands available xspager/sailor@4347e44, what you think?

@mpeterv
Copy link
Owner

mpeterv commented Nov 19, 2016

@xspager sorry for not following up on this! I see that sailor has switched to argparse already, so this must have been resolved. The commit you've linked makes sailor show full help on misuse, which is a a valid option. Do you still want to be able to list all options in help, including option specific to each command? If so, we could keep this open as a feature request but I'm not sure how to layout help for options nested in commands.

@xspager
Copy link
Author

xspager commented Nov 21, 2016

It might be better to ask @Etiene about that 😕

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

2 participants