Coder Social home page Coder Social logo

Comments (6)

DannyBen avatar DannyBen commented on June 16, 2024

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.

RicardoM17 avatar RicardoM17 commented on June 16, 2024

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.

DannyBen avatar DannyBen commented on June 16, 2024

Alright.

  1. There is most likely a way to implement it yourself, say, as a cli help command or something, and utilizing the *_usage() functions.
  2. In addition, you can use the bashly render command to render this command automatically.
  3. I will try to implement the above as an example, to see how it looks.
  4. I am open to the idea of adding this as a feature, or at least as an example for "self service" implementation.

from bashly.

DannyBen avatar DannyBen commented on June 16, 2024

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.

RicardoM17 avatar RicardoM17 commented on June 16, 2024
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.

DannyBen avatar DannyBen commented on June 16, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.