Skip to content
Snippets Groups Projects
Verified Commit da41b498 authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

refactor change func name FlagOutput() to Output()

parent ff56b593
No related branches found
No related tags found
No related merge requests found
......@@ -79,6 +79,9 @@ the command `serve`. Furthermore, the command has the tag `call` with
the value `DoServe`. The function `DoServe` is called when the command
`serve` is used.
Important: The function must be exported, that means it
must start with a capital letter.
The function is called with the receiver `*Definition`
An example for the function `DoServe`:
......
......@@ -34,8 +34,8 @@ func New[C any](name string, definitions C) *Settings[C] {
return s
}
// FlagOutput returns the writer where the flag package writes its output.
func (s *Settings[C]) FlagOutput() string {
// Output returns the writer where the flag package writes its output.
func (s *Settings[C]) Output() string {
return s.flagOutput.(*bytes.Buffer).String()
}
......
......@@ -8,6 +8,23 @@ import (
"testing"
)
func TestUsage(t *testing.T) {
commands := New("root", CmdTest1{})
args := []string{"-h"}
commands.Parse(args)
assert.False(t, commands.HasErrors())
if commands.HasErrors() {
t.Log(commands.Errors())
}
usage := commands.Usage()
assert.NotEmpty(t, usage)
}
func TestNewIntWithError(t *testing.T) {
// two is not a struct
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment