Show help when no sdlcli arguments 27/7127/1
authorTimo Tietavainen <timo.tietavainen@nokia.com>
Thu, 25 Nov 2021 17:44:53 +0000 (19:44 +0200)
committerTimo Tietavainen <timo.tietavainen@nokia.com>
Thu, 25 Nov 2021 17:44:53 +0000 (19:44 +0200)
Implement showing of the help text also when sdlcli tool is called
without any arguments.

Issue-Id: RIC-113

Signed-off-by: Timo Tietavainen <timo.tietavainen@nokia.com>
Change-Id: I6ebd9844fe09debeeb24946ba55ebfb2d7b807c3

internal/cli/root.go
internal/cli/root_test.go

index c5cf5ac..502c42b 100644 (file)
@@ -36,6 +36,7 @@ func newRootCmd() *cobra.Command {
                Short: "Shared Data Layer (SDL) troubleshooting command line tool",
                Long:  `Shared Data Layer (SDL) troubleshooting command line tool`,
                Run: func(cmd *cobra.Command, args []string) {
+                       cmd.Help()
                },
        }
 }
index 947a6c0..74124f4 100644 (file)
@@ -39,6 +39,7 @@ func TestCliShowsHelp(t *testing.T) {
                expErr    error
                expOutput string
        }{
+               {args: "", expErr: expOkErr, expOutput: expHelp},
                {args: "-h", expErr: expOkErr, expOutput: expHelp},
                {args: "--help", expErr: expOkErr, expOutput: expHelp},
                {args: "--some-unknown-flag", expErr: expNokErr, expOutput: expHelp},
@@ -50,6 +51,7 @@ func TestCliShowsHelp(t *testing.T) {
                cmd.SetOut(buf)
                cmd.SetErr(buf)
                cmd.SetArgs([]string{test.args})
+
                err := cmd.Execute()
                result := buf.String()
                assert.Equal(t, test.expErr, err)