An open API service providing package, version and dependency metadata of many open source software ecosystems and registries.

github.com/posener/cmd

Package cmd is a minimalistic library that enables easy sub commands with the standard `flag` library. This library extends the standard library `flag` package to support sub commands and more features in a minimalistic and idiomatic API. Features: - [x] Sub commands. - [x] Automatic bash completion. - [x] Flag values definition and check. - [x] Explicit positional arguments definition. - [x] Automatic usage text. Define a root command object using the `New` function. This object exposes the standard library's `flag.FlagSet` API, which enables adding flags in the standard way. Additionally, this object exposes the `SubCommand` method, which returns another command object. This objects also exposing the same API, enabling definition of flags and nested sub commands. The root object then have to be called with the `Parse` method, similarly to the `flag.Parse` call. * Minimalistic and `flag`-like. * Any flag that is defined in the base command will be reflected in all of its sub commands. * When user types the command, it starts from the command and sub commands, only then types the flags and then the positional arguments: * When a command defines positional arguments, all its sub commands has these positional arguments and thus can't define their own positional arguments. * When flag configuration is wrong, the program will panic. Definition and usage of sub commands and sub commands flags. In the cmd package, positional arguments should be explicitly defined. They are defined using the `Args` or `ArgsVar` methods. An example of how to parse positional arguments using a custom function. It enables the advantage of using named variables such as `src` and `dst` as opposed to args[0] and args[1]. An example of defining int positional arguments. An example of defining an exact number of positional arguments. An example that shows how to use advanced configuration of flags and positional arguments using the predict package.

Ecosystem
proxy.golang.org
Latest Release
v1.3.4
over 5 years ago
Versions
8
Dependent Packages
8
Dependent Repos
5
Links
Registry proxy.golang.org
Source Repository
Docs Documentation
JSON API View JSON
CodeMeta codemeta.json
Package Details
PURL pkg:golang/github.com/posener/cmd
spec
License Apache-2.0
Namespace github.com/posener
First Release over 6 years ago
Last Synced 21 days ago
Repository
Stars 44 on GitHub
Forks 3 on GitHub
Rankings on proxy.golang.org
Overall Top 5.4%
Dependent packages Top 1.9%
Dependent repos Top 2.3%