cmdr
cmdr
is a POSIX-compliant, command-line UI (CLI) library in Golang. It is a getopt-like parser of command-line options, be compatible with the getopt_long command line UI, which is an extension of the syntax recommended by POSIX.
We made many enhancements beyond the standard library flag
.
There is a full Options Store
(configurations) for your hierarchical configuration dataset too.
The .netCore version Cmdr.Core is available now. And, a cxx version cmdr-cxx
is comming soon.
To review the image frames, go surfing at https://github.com/hedzr/cmdr/issues/1#issuecomment-567779978
Table of Contents
Youtube – 李宗盛2013最新單曲 山丘 官方完整版音檔 / Jonathan Lee – Hill CHT + ENU
Import
The better choice is importing with go-modules enabled:
import "github.com/hedzr/cmdr"
See our extras:
- cmdr-docs: documentations (Working)
- cmdr-addons: a new daemon plugin
dex
for linux/macOS/windows. - cmdr-examples: collects the samples for cmdr
News
-
docs (WIP):
- english documentation NOT completed yet
- documentation at: https://hedzr.github.io/cmdr-docs/
-
v1.7.42
- routine maintenance
-
v1.7.41
- fixed: flags after tail-args might not be recognized. NOTE: in
app cmd1 cmd2 --a file1 file2 --c
,--c
might be ignored. - updated: log+logex
- fixed: flags after tail-args might not be recognized. NOTE: in
-
v1.7.40
- update log/logex to fix the wrong caller skips for logrus
-
v1.7.39
- update log/logex to fix the wrong caller skips for zap/sugar, and ensure debug mode work
-
v1.7.38
- improved the usage line in help screen
-
v1.7.37
- added
WithAlterLocations(...)
- broken: LoadConfigFiles returns 3 values now
- added
-
v1.7.36
- fixed
GetSectionFrom()
now work for []interface{}. such as:inform: - name: xx url: xx - name: yy url: yy
- print error detail while loading and merging child config file failed
- fixed
-
v1.7.35
- update deps with log/logex fixed
-
v1.7.33
- added project-level files
- update deps
-
v1.7.32
- added WithWarnForUnknownCommand
- fixed bugs
-
v1.7.31
- added alternative config file and folder:
$CURRDIR/.<appname>.yml
&$CURRDIR/.<appname>/*.yml
– UsingWithSearchAlterConfigFiles(true)
- configurable auto-sub-folder-name
conf.d
:WithConfigSubDirAutoName(string)
- added alternative config file and folder:
-
v1.7.30
- added docker hub image for examples/fluent
-
v1.7.29
- added docker image for examples/fluent
- added cmdr.InDockerEnv
- small fixes
-
v1.7.28
- added cmdr.NewLoggerConfigWith for better smoothing transfer cmdr internal status to log/logex.
- added cmdr.InDevelopingTime
- better output in PassThruChar(–) detected
- doc and added SetTraceMode/SetDebugMode
-
v1.7.27
- added:
WithHelpScreenHooks
,GetRemainArgs
, … - improved:
WithPagerEnabled
,InTesting
, … - fixed: missed initializing for
logger-level
inOption Store
sometimes. - tests
- added:
-
v1.7.25
- New feature: loading command definition from config file
- fixed bugs
-
v1.7.23
- A new feature: the builtin pluggable cmdr-addon/plugin.
make build && bin/fluent --help && bin/fluent dx
- added:
WithPluginLocations(locations...)
,WithExtensionsLocations(locations...)
- A new feature: the builtin pluggable cmdr-addon/plugin.
-
v1.7.21
- A new feature: the builtin pluggable extensions (see also: cmdr-examples/flags )
-
v1.7.11
- update: new log.Logger instance in log.GetLogger
- fixed: ReadPassword in windows
-
v1.7.10
- fixed: too much empty lines in help screen
-
v1.7.9
- right align multi-lines desc string in help screen
- added new envvars: HELP, NO_COLOR (
HELP=1 app some sub cmd
==app some sub cmd --help
)
-
v1.7.8
- tabStop in help screen will be autosize now
- deprecated at next minor release (v1.8+):
WithHelpTabStop()
- deprecated at next minor release (v1.8+): plugins/daemon
- BREAK: some two methods in the interface
Painter
has been changed.
-
v1.7.7
- update deps to improve logging supports
- deprecated:
WithLogex()
, as its replacement,WithLogx()
has a better generic logging interface (hedzr/log.Logger)
-
v1.7.6:
- using hedzr/log and remove other logging dependencies.
- added
WithLogx(logger)
: integrating with your logger (vialog.Logger
interface)
-
v1.7.5:
- move some helper function to
tool
sub-package
- move some helper function to
-
For more information to refer to CHANGELOG
Features
Old README.md: README.old.md
About the Docker build
Here is a docker build for cmdr/examples/fluent so that you can run it without go building or downloading the release files:
# from Docker Hub:
$ docker run -it --rm hedzr/cmdr-fluent
$ docker run -it --rm hedzr/cmdr-fluent --help
# from Github Packages (please following the guide of GitHub Packages Site):
$ docker run -it --rm docker.pkg.github.com/hedzr/cmdr/cmdr-fluent
$ docker run -it --rm docker.pkg.github.com/hedzr/cmdr/cmdr-fluent --help
For Developer
Examples
-
short
simple codes with structured data style. -
demo
normal demo with external config files. -
wget-demo
partial-covered for GNUwget
. -
fluent
demostrates how to define your command-ui with the fluent api style. -
a demo to show you how to migrate from go
flag
smoothly. -
cmdr-http2
http2 server with daemon supports, graceful shutdown -
awesome-tool
awesome-tool
is a cli app that fetch the repo stars and generate a markdown summary, accordingly with most of awesome-xxx list in github (such as awesome-go).
See Also the examples index: Examples.md (zh-cn TODO: Examples.zh-cn.md)
Uses
- https://github.com/hedzr/consul-tags
- https://github.com/hedzr/ini-op
- https://github.com/hedzr/awesome-tool
- austr
- Issue me to adding yours
Contrib
Feel free to issue me bug reports and fixes. Many thanks to all contributors.
Thanks to JODL
JODL (JetBrains OpenSource Development License) is good:
License
MIT