diff --git a/VERSION b/VERSION index 77989f5..0b71bb7 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v2.0.9 \ No newline at end of file +v2.0.10 \ No newline at end of file diff --git a/alias_test.go b/alias_test.go index 85e970a..c512a6f 100644 --- a/alias_test.go +++ b/alias_test.go @@ -15,7 +15,6 @@ func TestWithAlias(t *testing.T) { figs.NewString(cmdLong, valueLong, usage) figs.WithAlias(cmdLong, cmdAliasLong) assert.NoError(t, figs.Parse()) - t.Log(figs.Usage()) assert.Equal(t, valueLong, *figs.String(cmdLong)) assert.Equal(t, valueLong, *figs.String(cmdAliasLong)) @@ -33,7 +32,6 @@ func TestWithAlias(t *testing.T) { figs.WithAlias(k, ka2) figs.WithAlias(k, ka3) assert.NoError(t, figs.Parse()) - t.Log(figs.Usage()) assert.Equal(t, v, *figs.String(k)) assert.Equal(t, v, *figs.String(ka1)) @@ -56,7 +54,7 @@ func TestWithAlias(t *testing.T) { figs.WithValidator(cmdShort, AssureStringNotEmpty) assert.NoError(t, figs.Parse()) - t.Log(figs.Usage()) + // long assert.Equal(t, valueLong, *figs.String(cmdLong)) assert.Equal(t, valueLong, *figs.String(cmdAliasLong)) @@ -73,7 +71,6 @@ func TestWithAlias(t *testing.T) { figs.NewInt("count", 42, "usage") figs.WithAlias("count", "c") assert.NoError(t, figs.Parse()) - t.Log(figs.Usage()) assert.Equal(t, 42, *figs.Int("count")) assert.Equal(t, 42, *figs.Int("c")) }) @@ -86,6 +83,5 @@ func TestWithAlias(t *testing.T) { figs.WithAlias("two", "x") // Should this overwrite or be ignored? assert.NoError(t, figs.Parse()) assert.Equal(t, "value1", *figs.String("x")) // Clarify expected behavior - t.Log(figs.Usage()) }) } diff --git a/figtree.go b/figtree.go index 489873c..3c32280 100644 --- a/figtree.go +++ b/figtree.go @@ -79,6 +79,7 @@ func With(opts Options) Plant { mutationsCh: make(chan Mutation), flagSet: flag.NewFlagSet(os.Args[0], flag.ContinueOnError), } + fig.flagSet.Usage = fig.Usage angel.Store(false) if opts.IgnoreEnvironment { os.Clearenv() diff --git a/types.go b/types.go index bbacf86..a4aae92 100644 --- a/types.go +++ b/types.go @@ -173,7 +173,7 @@ type Core interface { ErrorFor(name string) error // Usage displays the helpful menu of figs registered using -h or -help - Usage() string + Usage() } // Plant defines the interface for configuration management. diff --git a/usage.go b/usage.go index ae9a78d..7da4443 100644 --- a/usage.go +++ b/usage.go @@ -11,7 +11,7 @@ import ( ) // Usage prints a helpful table of figs in a human-readable format -func (tree *figTree) Usage() string { +func (tree *figTree) Usage() { termWidth := 80 if term.IsTerminal(int(os.Stdout.Fd())) { if width, _, err := term.GetSize(int(os.Stdout.Fd())); err == nil { @@ -79,7 +79,7 @@ func (tree *figTree) Usage() string { } }) - return sb.String() + fmt.Println(sb.String()) } // wrapText wraps a line of text to fit within the terminal width, indenting wrapped lines