Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ func run() (exitCode int) {
registerAuthCommands(configDir)
registerCustomerContextCommands(configDir)
registerUpgradeCommand(configDir)
registerVersionCommand()
registerSkillCommands()
// Unhide the customer-context command for DoiT employees so it appears in help.
if cachedTokenIsDoer() {
Expand Down Expand Up @@ -1118,6 +1119,17 @@ func registerStatusCommands(configDir string) {
})
}

func registerVersionCommand() {
cli.Root.AddCommand(&cobra.Command{
Use: "version",
Short: "Print the DCI CLI version",
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
fmt.Fprintln(os.Stdout, version)
},
})
}

// applyAPIKeyAuth injects DCI_API_KEY into restish's auth cache as a Bearer
// token. Restish's OAuth TokenHandler checks the cache before triggering a
// browser flow, so pre-populating it bypasses interactive login. We use
Expand Down
16 changes: 16 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,22 @@ func TestNormalizeArgs(t *testing.T) {
}
}

func TestRegisterVersionCommand(t *testing.T) {
setupTestRoot(t)
registerVersionCommand()

command, _, err := cli.Root.Find([]string{"version"})
if err != nil {
t.Fatal(err)
}
if command.Name() != "version" {
t.Fatalf("command = %q, want version", command.Name())
}
if command.Short != "Print the DCI CLI version" {
t.Fatalf("short description = %q", command.Short)
}
}

func TestRejectProfileFlags(t *testing.T) {
setupTestRoot(t)

Expand Down
Loading