thatisuday / commando Goto Github PK
View Code? Open in Web Editor NEWAn easy-to-use command-line application builder.
Home Page: https://pkg.go.dev/github.com/thatisuday/commando
License: MIT License
An easy-to-use command-line application builder.
Home Page: https://pkg.go.dev/github.com/thatisuday/commando
License: MIT License
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}
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
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?
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) {
...
})
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.
A lot of tools allow you to do main help <sub>
instead of main <sub> --help
. Would be nice to support this.
When there's an error parsing, commando is returning an exit code of 0 as if everything went fine. Shouldn't it return non zero to signal failure?
Line 293 in 3b7ef11
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.
I didn't type this. It's the default - informationn with two n's.
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?
HI,
Is there possibility to create nested sub-commands, something like:
tree info jobs
tree info peoples
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.