Argonaut

Builder style CLI creation kit.

MIT License

Stars
0
Committers
7

= Argonaut :repo: https://github.com/Foxcapades/Argonaut

++++

Argonaut is a builder-style CLI creation kit packed with features.

image:https://img.shields.io/github/license/Foxcapades/Argonaut[GitHub] image:https://img.shields.io/github/v/tag/Foxcapades/Argonaut?label=version[GitHub tag (latest SemVer), link=https://github.com/Foxcapades/Argonaut/releases/latest] image:https://goreportcard.com/badge/github.com/Foxcapades/Argonaut[link=https://goreportcard.com/report/github.com/Foxcapades/Argonaut] image:https://img.shields.io/badge/go-docs-blue[Static Badge,link=https://pkg.go.dev/github.com/Foxcapades/Argonaut] image:https://img.shields.io/badge/wiki-docs-purple[Wiki,link=https://github.com/Foxcapades/Argonaut/wiki]

[source, go]

import (
cli "github.com/Foxcapades/Argonaut"
)

== Features

  • Builder-style API.

[source, go]

cli.Flag().
WithArgument(cli.Argument().
WithName("file").
Require())

  • Build singular command applications or command trees.

[source, go]

cli.Command()
// OR
cli.Tree()

  • Overridable automatic help text generation.

[source, console]

Usage: my-app [options] This is a simple command tree example.

Flags -h | --help Prints this help text.

Commands
fizz Aliases: fi
This is the description for the fizz branch.
foo Aliases: fo
this is the description for the foo branch

  • Bind command line arguments to variables of arbitrary types.

[source, go]

foo := uint8(0)

cli.Argument().WithBinding(&foo)

  • Multi-use flags.

[source, console]

$ foo --bar --bar --bar
bar = 3

  • Stackable short flags.

[source, console]

$ app -abc=4
a = true
b = true
c = 4

  • Callback hooks.

[source, go]

cli.Flag().WithCallback(func(Flag){})
cli.Command().WithCallback(func(Command){})
cli.Tree().WithCallback(func(Tree){})
cli.Branch().WithCallback(func(Branch){})
cli.Leaf().WithCallback(func(Leaf){})

  • Customizable or overridable unmarshalling of almost any type.

[source, go]

var options argo.UnmarshalProps
...
cli.Argument().WithUnmarshaler(argo.NewMagicUnmarshaler(options))

  • Default values for flags and arguments.

[source, go]

var foo int32
cli.Argument().WithBinding(&foo).WithDefault(int32(666))

  • Input validation hooks.

[source, go]

var bind uint8
cli.Argument().
WithBinding(&bind)
WithValidator(func(string) {}).
WithValidator(func(string, int8) {})

  • Automatic capturing of "passthrough" flags and arguments.

[source, console]

$ foo bar --fizz=buzz -- apple banana canteloupe
Passthroughs: apple, banana, canteloupe

  • And more!

== Examples

. https://github.com/Foxcapades/Argonaut/tree/master/examples/complex-type[Complex Types] . https://github.com/Foxcapades/Argonaut/tree/master/examples/number-extras[Number Format Extras] . https://github.com/Foxcapades/Argonaut/tree/master/examples/simple-tree[Simple Tree]