Add sample-complex.
5 files changed
tree: 337ccd50056fecf6366aed0797c89f6c5918266d
  1. .github/
  2. sample-complex/
  3. sample-simple/
  4. subcommandstest/
  5. .gitignore
  6. codecov.yml
  7. go.mod
  8. go.sum
  9. LICENSE
  10. logger.go
  11. README.md
  12. subcommands.go
  13. subcommands_test.go
README.md

subcommands golang library

This package permits a Go application to implement subcommands support similar to what is supported by the ‘go’ tool.

The library is designed so that the test cases can run concurrently. Using global flags variables is discouraged to keep your program testable concurrently.

The intended command is found via heuristic search;

  • exact match
  • unique prefix, e.g. lo will run longcommand as long as there's no command with the same prefix.
  • case insensitivity; for those weird enough to use Upper Cased Commands.
  • levenshtein distance; where longcmmand or longcmomand will properly trigger longcommand.

PkgGoDev Coverage Status

Examples

  • See sample-simple for a barebone sample skeleton usable as-is.
  • See sample-complex for a complex sample using advanced features.
  • See module subcommands/subcommandstest for tools to help testing an application using subcommands. One of the main benefit is t.Parallel() just works, because subcommands help wrapping global variables.