datadrake / cli-ng Goto Github PK
View Code? Open in Web Editor NEWAn easy to use CLI library for the Go language
License: Apache License 2.0
An easy to use CLI library for the Go language
License: Apache License 2.0
Localization should be defined that is specific to cli-ng first, with enough generic functionality to also be used by the applications which are based on cli-ng.
Localization should be defined using the Weblate-supported nested-json format.
https://docs.weblate.org/en/latest/formats.html#json-files
Something like:
{
"cli-ng": {
"usage": "USAGE",
"cmd": "CMD",
"desc": "DESCRIPTION"
},
"cli-ng-root": {
"flag-name": "name",
"flag-name-desc": "This is name"
},
"cli-ng-subcommand": {
"arg-name": "name",
"arg-name-desc": "this is name",
"flag-name2": "name2",
"flag-name2-desc": "This is name2"
}
}
Weblate testing is needed for > 2 levels of nesting. Docs are unclear. If possible, more like:
{
"cli-ng": {
"usage": "USAGE",
"cmd": "CMD",
"desc": "DESCRIPTION",
"arg": "arg",
"cmds": {
"root": {
"short": "root command description",
"flags": {
"name1": {
"short": "n",
"long": "long-name",
"desc": "This is name"
}
}
},
"subcommand": {
"name": "subcommand1",
"alias": "sc",
"short": "this is subcommand1",
"args": {
"name2": {
"name": "name2",
"desc": "this is name2"
}
},
"flags": {
"name3": {
"short": "N",
"long": "long-name3",
"desc": "this is name3"
}
}
}
}
}
}
Hey @DataDrake,
On one of the projects I'm working on I'd kinda love to be able to nest subcommands. For example,
hyprspace peers add
hyprspace peers remove
Where hyprspace
is the name of the program, peers
is the top level subcommand, and add/remove
are children of peers
.
Looking around I didn't see an obvious way to do this in cli-ng
but, perhaps I'm just not looking in the right place? If this isn't already implemented, would this be something you are interested in?
Trying to package cuppa
for Void Linux and running into this error.
# github.com/DataDrake/cli-ng/translate
_build-cuppa-xbps/src/github.com/DataDrake/cli-ng/translate/en_US.go:29:10: cannot use enUS (type string) as type []byte in argument to po.Parse
Not really an easter egg sort of thing. It would be nice to have hidden subcommands for things like:
No, we aren't going to generate a bash completion script. We should have a hidden "completions" subcommand which may be called from a light-weight script to adapt it to Bash and other shells.
If I wanted to use the equivalent of the Python append argument, how would that look? E.g., I'd want to be able to do:
./executable <command> --metric one --metric two ... --metric N
The alternative is provide one string separated by commas, which isn't as nice an interface. it's also not appropriate to use a list of args because I'm already using it for something else. Thank you!
It's inevitable that someone will want to see us generating man pages. This should be implemented as a simple text\template
which dumps out a man page in the default locale. These man pages should mirror how git
does them: one man page for the whole utility, referencing individual man pages for each non-hidden subcommand (e.g. git-commit).
At the moment, you must specify the long and short as struct tags for a flag in order for them to be usable. Ideally it should default to the struct field name being lowercased.
The argument struct for a subcommand should be able to have the last argument be a slice of one of the other supported types. This allows the command to take a list of arguments rather than just one argument per struct entry.
Subcommands should be allowed to be called without any arguments, even if they are specified. This allows a single subcommand to be used to operate on a specific thing or all things. In conjunction with slice args, any number of arguments 0...N can therefore be supported.
Right now, only the Root command is allowed to have Flags. All subcommands should be allowed to define additional flags, specific to their operation.
When creating a new cmd.CMD
, if the Args
field is left unassigned, the program fails with the following stack trace:
panic: reflect: call of reflect.Value.Elem on zero Value
goroutine 1 [running]:
reflect.Value.Elem(0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
/usr/lib64/golang/src/reflect/value.go:842 +0x1a5
github.com/DataDrake/cli-ng/options.(*Parser).SetArgs(0xc00000e0a0, 0x0, 0x0, 0x7)
/home/serebit/Code/Go/pkg/mod/github.com/!data!drake/[email protected]/options/parser.go:161 +0xc8
github.com/DataDrake/cli-ng/cmd.(*RootCMD).Run(0x5e6b00)
/home/serebit/Code/Go/pkg/mod/github.com/!data!drake/[email protected]/cmd/root.go:122 +0x14d
main.main()
/home/serebit/Code/Go/qol-assist/main.go:20 +0x2d
Setting Args
to &struct{}{}
works around this.
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.