Giter Site home page Giter Site logo

thatisuday / commando Goto Github PK

View Code? Open in Web Editor NEW
137.0 137.0 16.0 1.64 MB

An easy-to-use command-line application builder.

Home Page: https://pkg.go.dev/github.com/thatisuday/commando

License: MIT License

Go 100.00%
cli cli-tool go golang golang-library golang-package

commando's People

Contributors

fragoulis avatar koerel avatar thatisuday avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

commando's Issues

Help does not display sub command

Looking at the example from the readme I noticed that Commando doesn't display the correct information.

It shows the red one, but I expected to see the green one:

 $ reactor create -h
 
 This command creates a component of a given type and outputs component files in the project directory.
 
 Usage:
-  reactor <name> [version] [files] {flags}
+  reactor create <name> [version] [files] {flags}

How to write shell completion function in Go

For example the following is a zsh completion function for command foo:

#compdef _foo foo
compadd first second third fourth

So, if we type foo <tab> in the zsh terminal, it suggests first second third fourth.

How can I do this using commando?

Consider less verbose Action signature

Just a thought but you introduce 2 types to make the func taken by SetAction a little easier on the eyes:

type CliArgs map[string]commando.ArgValue
type CliFlags flags map[string]commando.FlagValue
SetAction(func(args CliArgs, flags CliFlags) {
   ...   
})

Client code would have easier to read signatures on these actions.

Or event a single struct to hold both:

type Cli struct {
	Args map[string]commando.ArgValue
	Flags map[string]commando.FlagValue
}
SetAction(func(cli Cli) {
   ...   
})

Add optional argument with empty default value

First of all: this library looks amazing! Great work!

Currently, there is no way to register an optional argument, unless you add an argument with a default value that is not an empty string.

So for example:

// $ reactor create <name> [version]
commando.
	Register("create").
	SetShortDescription("creates a component").
	AddArgument("name", "name of the component to create", "").                                  // required
	AddArgument("version", "version of the component", "1.0.0").     

Version is optional here because it has a default value that is not an empty string.

For my use case, I want to add an optional value that itself is an empty string by default.

That doesn't work because of this rule:

IsRequired: defaultValue == "" && !clpArg.IsVariadic, // variadic arguments are always optional

I would like to have something like this:

// $ reactor create <name> [version]
commando.
	Register("create").
	SetShortDescription("creates a component").
	AddArgument("name", "name of the component to create", "").                                  // required
	AddOptionalArgument("version", "optional version to create", "").     

Any idea how to solve this?

Help is not printed in some circumstances

When creating an app where the root command is empty and has no flags or arguments but my app has a bunch of other subcommands, for example like the Go or Git commands, running the help with no arguments causes it to do nothing. This could be potentially confusing for users, so it would be nice if help were automatically printed.
Also, when not filling in a required argument or typing an invalid subcommand, some usage info could be displayed to help the user figure out the problem faster.

Nested sub-commands

HI,
Is there possibility to create nested sub-commands, something like:
tree info jobs
tree info peoples

How do you test a command?

tl:dr; If I write a command, how do I test it

I've been using your Commando for a little while now. Very similar to PHP Symfony Console, which I have used since God was a small child. Now I need to unit test some production code that uses it. It's a bit opaque as to how you might do that. So just a little bit of documentation on how to set up a command so it can be tested in a unit test would be very gratefully appreciated.

Don't worry about virtual file systems - that's a subject for another repo (may come back here ;-) )

Regards
chippyash

Flag operation not as described

Hi.

I hope you are having a great new year so far.

Using this package, I can create an application which has foo <command> {flags} as an option, great. The only commands I have are help and version, okay. When I pass any of my listed flags to either of these commands, I receive a message: Error: <flag name> is not a valid flag.

Could a change be made to not output the {flags} portion of foo <command> {flags} when the only commands are help and version?

Thanks in advance.

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.