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

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

cmdr is a POSIX/GNU style, command-line UI (CLI) Go library. 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.

There are couples of enhancements beyond the standard library flag.

There is a full Options Store (configurations) for your hierarchy configuration data too.

ee99d078e2f7

To review the image frames, go surfing at #1 (comment)

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:

News

  • v1.6.51 (WIP)

    • deprecated: daemon plugin
  • v1.6.50

    • fixed: correct the error printing while wrong args got
    • fixed: valid-args - ensure the found flag as a value matched
    • fixed: withIgnoredMessage - format with liveArgs
    • cmd.NewFlagV was deprecated since v1.6.50, we recommend the new form: cmdr.NewBool(false).Titles(...)...AttachTo(ownerCmd)
    • better Titles(long, ...) and Name(name)
      Now you can compose the order prefix easily: with .Titles("001.start"), we can recognize the prefix and move it to Name field automatically.

    We will remove the deprecated api at next minor version (v1.7)

  • v1.6.49

    • added: Name() for command & flag defining
  • v1.6.48

    • code reviewed
    • maintained
    • unnecessary deps removed.
    • small fixes
  • v1.6.47

    • fixed/improved: reset slice value if an empty slice was been setting
    • improved: add logging output in delve debugging mode
    • fixed: matching the longest short flag for combining flags
    • BROKEN API: the param defaultValue is optional now: cmdr.NewBool(), cmdr.NewInt(), ...
    • added cmdr.NewUintSlice()
  • v1.6.45

    • fixed/improved: ToBool(value, defval...) bool
    • fixed: flag.OnSet trigger for envvar hit
    • fixed/improved: friendly error msg
  • v1.6.43

    • fixed/improved: the matching algorithm and remained args
  • v1.6.41

    • WithPagerEnabled(): enables OS pager for help screen output
  • v1.6.39

    • BROKEN API: the params order exchanged, their new prototypes are OptFlag.Titles(long, short, aliases) and OptCmd.Titles(long, short, alases).
    • improved help screen
    • bug fixed:
      • the value of remained args could be wrong sometimes
      • stop flag split in parsing
      • some coverage test errors
  • v1.6.36

    • ToggleGroup:
      • assume the empty Group field with ToggleGroup
      • set "command-path.toggleGroupName" to the hit flag full name as flipping a toggle-group.
        For example, supposed a toggle-group 'KK' under 'server' command with 3 choices/flags: apple, banana, orange. For the input '--orange', these entries will be set in option store:
        server.orange <== true;
        server.KK <== 'orange';
    • fixed: GetStringSliceXxx() return the value array without expand the envvar.
    • improved: some supports for plan9
    • fixed: can't expand envvar correectly at earlier initializing.
  • For more information to refer to CHANGELOG

Features

Features.md

Old README.md: README.old.md

For Developer

For Developer

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

    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

JODL (JetBrains OpenSource Development License) is good:

goland jetbrains

License

MIT

FOSSA Status