Skip to content

Releases: jwaldrip/odin

Version 1.8.0

24 Nov 15:07
Compare
Choose a tag to compare

Sub commands can now be aliased.

Version 1.7.0

05 Nov 19:01
Compare
Choose a tag to compare

Features:

Outputs functionality is now part of odin.

Output Helpers

Output is possible directly on the CLI and is prefered over using fmt. Available commands map to their fmt counterparts.

method description
ErrPrint(a ...interface{}) Prints to the err output.
ErrPrintf(format string, a ...interface{}) Prints formatted to the err output.
ErrPrintln(a ...interface{}) Prints a line to the err output.
Print(a ...interface{}) Prints to the std output.
Printf(format string, a ...interface{}) Prints formatted to the std output.
Println(a ...interface{}) Prints a line to the std output.
package main

import "github.com/jwaldrip/odin/cli"

app := cli.New("1.0.0", "my app", func(c cli.Command){
  c.Println("hello world")
  c.ErrPrintln("There was an error")
} 

Custom Output

Any io.Writer can be used as an output

outbuffer := bytes.NewBufferString("")
errbuffer := bytes.NewBufferString("")
app.SetStdOut(outbuffer)
app.SetStdErr(errbuffer)

Version 1.6.2

29 Oct 03:58
Compare
Choose a tag to compare

Fixes

Fixes sub command ordering issue reported by @ddollar (#16).

Version 1.6.1

28 Oct 22:08
Compare
Choose a tag to compare

Fixes

Help was updated to ensure all descriptions for flags and commands line up properly.

before:

$ go run -- examples/greet-with/main.go hello to -h
Usage:
  main [options...] <greeting> to <greetee>

Say a greeting to a specific persion

Example:
  $ greet-with hello to jerry
  hello jerry

Options:
  -h, --help  # show help and exit

Options for `main`:
  -c, --color="blue"  # color the output (red, blue, green)
  -h, --help          # show help and exit
  -l, --loudly        # say loudly
  -v, --version       # show version and exit

after:

$ go run -- examples/greet-with/main.go hello to -h
Usage:
  main [options...] <greeting> to <greetee>

Say a greeting to a specific persion

Example:
  $ greet-with hello to jerry
  hello jerry

Options:
  -h, --help           : show help and exit

Options for `main`:
  -h, --help           : show help and exit
  -v, --version        : show version and exit
  -l, --loudly         : say loudly
  -c, --color=blue     : color the output (red, blue, green)

Version 1.6.0

26 Oct 22:53
Compare
Choose a tag to compare

Features

  • Supports for long descriptions using SetLongDescription() which will only show up on --help invoked directly on a command.

Enhancements

  • Help is now slightly more verbose. Showing more information about the parent commands on sub commands.

    _example:_

    $ greet-with hello to -h
    Usage:
      greet-with [options...] <greeting> to <greetee>
    
    Say a greeting to a specific persion
    
    Example:
      $ greet-with hello to jerry
      hello jerry
    
    Options:
      -h, --help  # show help and exit
    
    Options for `greet-with`:
      -c, --color="blue"  # color the output (red, blue, green)
      -h, --help          # show help and exit
      -l, --loudly        # say loudly
      -v, --version       # show version and exit
    

Version 1.5.1

26 Oct 05:03
Compare
Choose a tag to compare

Fixes:

  • Flag not parsing when flags are placed after freeform arguments.

Version 1.5.0

23 Oct 20:00
Compare
Choose a tag to compare

Features

  • Odin now supports flags before or after the parameters for the given command.

_example:_

$ go run main.go hello --loudly
HELLO
$ go run main.go --loudly hello
HELLO

_main.go:_

package main

import (
    "fmt"
    "strings"

    "github.com/jwaldrip/odin/cli"
)

var app = cli.New("0.0.1", "say a word", func(c cli.Command) {
    str := c.Param("word").String()
    if c.Flag("loudly").Get() == true {
        str = strings.ToUpper(str)
    }
    fmt.Println(str)
})

func init() {
    app.DefineParams("word")
    app.DefineBoolFlag("loudly", false, "say it loudly")
}

func main() {
    app.Start()
}

View the PR: #13

Special thanks to @dcarley for this request!!

Version 1.4.3

21 Oct 06:16
Compare
Choose a tag to compare

Several Fixes Related to Sub Commands and Flag inheritance.

Version 1.4.2

19 Oct 17:11
Compare
Choose a tag to compare

_kudos to @dcarley:_

The default for ErrorHandling was changed from ContinueOnError to
PanicOnError 8c20e9b. However this didn't apply to sub-commands, which
continued to use ContinueOnError and would execute the sub-command
function (in addition to printing the usage message) when not passed
mandatory arguments.

Fix this by copying ErrorHandling from the parent when adding a new
sub-command. The additional test asserts that the sub-command raises a panic
and doesn't execute it's contents when it doesn't receive the correct number
of arguments. Mute is required to prevent the help message being printed
during the tests.

Version 1.4.1

14 Oct 05:48
Compare
Choose a tag to compare

Fixes:

  • #7 - When ErrorHandling is set to ContinueOnError ... an error is raised.