Coder Social home page Coder Social logo

Comments (5)

DannyBen avatar DannyBen commented on September 22, 2024

Not as an alias. Adding a cli help is actually equivalent to adding a command.
You can easily do it using this bashly.yml setup:

name: cli
help: Sample application
version: 0.1.0

commands:
- name: help
  help: Show help

and after running bashly g, you will get the src/help_command.sh placeholder - put this content in it:

long_usage=yes
cli_usage

which is exactly what is being called when you run cli --help.

Does this work for you?


The nice thing about this, is that you can also adopt this function to allow cli help COMMAND to get help for different commands.

See this example for a nice implementation.

from bashly.

niksfirefly avatar niksfirefly commented on September 22, 2024

Well for all commands I get
No help available for this command
I wonder what am I doing wrong?

I also found another solution
with
extensible: true
and cli-help script
but your seems more practical
regards

from bashly.

DannyBen avatar DannyBen commented on September 22, 2024

Well, look at your generated script, and search for "--help" to see which function it calls.

All the occurrences of cli_* in the example, should be replaced with your script name (the cli prefix is the name of the default script) - lines 6 and 9 below.

if [[ -z "$command" ]]; then
# No command argument, show the global help
help_function=cli_usage
else
# Show the help for the requested command
help_function="cli_${command}_usage"
fi

As for the extensible option, it is not intended for it, although it can be used for it.
Bashly's goal is to have everything you need to write a good bash script in it. The extensible option is meant for you to give the users of your script the ability to extend it themselves if they want.

from bashly.

niksfirefly avatar niksfirefly commented on September 22, 2024

excellent !
I missed that my script is cli2
now it works
thank you
regards

from bashly.

DannyBen avatar DannyBen commented on September 22, 2024

Glad I could help.

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.