Skip to content
/ cmdr Public

POSIX-compliant command-line UI (CLI) parser and Hierarchical-configuration operations

License

Notifications You must be signed in to change notification settings

hedzr/cmdr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cmdr

Go GitHub tag (latest SemVer) GoDoc FOSSA Status go.dev Go Report Card codecov Coverage Status Mentioned in Awesome Go

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 fully-functional Options Store (configurations) for your hierarchical configuration dataset too.

The .netCore version Cmdr.Core is available now. And, a cxx version cmdr-cxx was pre-released just now (Happy Spring Festival 2021).

ee99d078e2f7

See the image frames at #1.

See our extras:

and Bonus of #cmdr Series:

News

  • docs (WIP):

  • v1.9.2 (WIP)

    • fixed: parsing not stop while a should-be-stopped flag (such as --version) found
    • fixed: incorrect usage line at top level help screen
    • improved: better toggle-group show in help screen
      new style for ToggleGroup items: A unicode character '⬡' as the prefix of the option description. (see here)
  • v1.9.1:

    • A public template repo may simplify your new CLI app: cmdr-go-starter.
    • crashed at an elder fsnotify on macOS, with go1.17
    • minor fixes
  • v1.9.0

    • .fossa.yaml so a pre-release scan can be launched locally
    • BREAK: remove plugin/daemon - use cmdr-addons/pkg/plugins/dex instead
    • updated log, added: closers, detects and more
    • use closers for better closing hooks
    • just a early BREAK release
  • v1.8.7

    • updated log, added: AutoStart Peripheral interface
  • v1.8.5

    • updated log, fixed: forwarding systemd log to file
  • v1.8.2

    • compliant with plan9,bsd,...
    • some data racing PRBs in parallel testing
  • v1.8.1

    • fixed the CI error by imported from log
    • fixed a data racing in config files watching
    • small imp: pprof - added validArgs for cmdr-opt profiling-type
    • update deps: log & logex(logrus indirect, ...)
  • v1.8.0

    • BREAK: removed support to golang 1.11 and below
    • update deps: log & logex(logrus indirect, ...)
  • v1.7.46

    • added plugin/pprof package to simplify pprof integration
    • slight improvements
  • More details at CHANGELOG

Features

Features.md

Old README.md: README.old.md

For Developer

For Developer

Import cmdr

With go-modules enabled:

import "github.com/hedzr/cmdr"

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

Examples

  1. short
    simple codes with structured data style.

  2. demo
    normal demo with external config files.

  3. wget-demo
    partial-covered for GNU wget.

  4. fluent
    demostrates how to define your command-ui with the fluent api style.

  5. ffdemo

    a demo to show you how to migrate from go flag smoothly.

  6. cmdr-http2
    http2 server with daemon supports, graceful shutdown

  7. 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

Contrib

Feel free to issue me bug reports and fixes. Many thanks to all contributors.

Thanks to JODL

Thanks to JetBrains for donating product licenses to help develop cmdr jetbrains

goland

License

MIT

FOSSA Status