From da41b498ea9a3f2107324a4b9f2b78c7b203a2d3 Mon Sep 17 00:00:00 2001
From: Volker Schukai <volker.schukai@schukai.com>
Date: Sat, 8 Oct 2022 16:46:30 +0200
Subject: [PATCH] refactor change func name FlagOutput() to Output()

---
 README.md   |  3 +++
 api.go      |  4 ++--
 api_test.go | 17 +++++++++++++++++
 3 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 6473bca..a65731f 100644
--- a/README.md
+++ b/README.md
@@ -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`:
diff --git a/api.go b/api.go
index 04f187d..37ea875 100644
--- a/api.go
+++ b/api.go
@@ -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()
 }
 
diff --git a/api_test.go b/api_test.go
index d402296..93a0169 100644
--- a/api_test.go
+++ b/api_test.go
@@ -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
-- 
GitLab