Comments (6)
Hmm. This behavior is the standard in most complex CLIs.
Otherwise, there is the potential for a very long and convoluted help message, where each command has its own argument help, environment variable help etc - all in one long output.
Can you point to any notable command that does that, so I have a better reference of what you expect to see?
from bashly.
For the record I'm not suggesting to change the current behavior of the cli help
command. That is perfectly fine and suitable for 99% of the use cases.
However we just had a situation in our use case where it would have been nice to have all the information in one go, rather than have it nested, but it's nothing very specific.
So we decided to check if there was a cli -h -v
or some other flag (no preference here) to recursively go through each command and add it to the output. Since there wasn't I decided to make a request here :D
I am not 100% sure what you are asking so apologies if I'm off the mark but the idea is that, from cli -h
where we get:
...
Commands:
start Start docker services
stop Stop docker services
...
We could get:
...
Commands:
start Start docker services
< output of cli start -h>
stop Stop docker services
< output of cli stop -h>
...
Maybe with some care to not repeat info.
from bashly.
Alright.
- There is most likely a way to implement it yourself, say, as a
cli help
command or something, and utilizing the*_usage()
functions. - In addition, you can use the
bashly render
command to render this command automatically. - I will try to implement the above as an example, to see how it looks.
- I am open to the idea of adding this as a feature, or at least as an example for "self service" implementation.
from bashly.
Try this for size.
In a new folder, create a new bashly project with colors
library:
$ bashly init
$ bashly add colors
add help
command to bashly.yml
:
commands:
- name: help
alias: h
help: Show full (recursive) help
generate:
$ bashly generate
edit src/help_command.sh
as follows:
cli_usage
echo
long_usage=1
bold "download command"
echo
cli_download_usage
echo
bold "upload command"
echo
cli_upload_usage
echo
generate and run:
bashly generate
./cli help
from bashly.
cli - Sample application
Usage:
cli COMMAND
cli [COMMAND] --help | -h
cli --version | -v
Commands:
download Download a file
upload Upload a file
help Show full (recursive) help
download command
cli download - Download a file
Alias: d
Usage:
cli download SOURCE [TARGET] [OPTIONS]
cli download --help | -h
Options:
--force, -f
Overwrite existing files
--help, -h
Show this help
Arguments:
SOURCE
URL to download from
TARGET
Target filename (default: same as source)
Environment Variables:
DEFAULT_TARGET_LOCATION
Set the default location to download to
Examples:
cli download example.com
cli download example.com ./output -f
upload command
cli upload - Upload a file
Alias: u
Usage:
cli upload SOURCE [OPTIONS]
cli upload --help | -h
Options:
--user, -u USER (required)
Username to use for logging in
--password, -p PASSWORD
Password to use for logging in
--help, -h
Show this help
Arguments:
SOURCE
File to upload
Looks pretty good.
from bashly.
Then you can do it for your app.
You can also render this file automatically, using the custom rendering feature.
At this point, it is unlikely to become a built-in bashly feature, for reasons I mostly mentioned already plus the fact that different users of such a feature might want a slightly different format.
from bashly.
Related Issues (20)
- Allow default array when repeatable is true HOT 9
- Add support for array in `flag.default` and `arg.default` schema HOT 1
- JSON schema validation passes when it shouldn't HOT 12
- Add JSON schema tests to ensure the validation fails when it should HOT 1
- Whitelisted arg with default from environment HOT 6
- Add `environment_variable.allowed` whitelist HOT 1
- Update `inspect_args` to also print managed environment variables HOT 1
- Docker container does not have pandoc installed HOT 2
- Do not render `inspect_args` when `env` is set to `production` HOT 2
- Add key-value parameters HOT 6
- Build multi-arch docker HOT 2
- Default argument is not validated HOT 6
- Flag arguments with a single hyphen prefix are not working HOT 1
- bash completions can't work properly when the position args used 'allowed:' HOT 3
- Repeatable args don't escape quotation marks HOT 12
- Add option to disable splitting of flags with value for catch_all arguments HOT 9
- Lifecycle for temporary directories HOT 1
- Heredoc indentation issue in bashly generated functions. HOT 9
- The Flag value is detected as an Argument HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bashly.