From ae1369746153880906bb636b676fd27cc0fa4221 Mon Sep 17 00:00:00 2001 From: Miguel de la Cruz Date: Sat, 29 Feb 2020 00:02:56 +0100 Subject: [PATCH] Adds the token structure --- cmd/root.go | 16 ++++++++++++---- cmd/token.go | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 cmd/token.go diff --git a/cmd/root.go b/cmd/root.go index f5bdc88..5906027 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -7,13 +7,21 @@ import ( "github.com/spf13/cobra" ) -var RootCmd = &cobra.Command{ - Use: "campaigner", - Short: "Create and manage Open Source campaigns", +func RootCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "campaigner", + Short: "Create and manage Open Source campaigns", + } + + cmd.AddCommand( + TokenCmd(), + ) + + return cmd } func Execute() { - if err := RootCmd.Execute(); err != nil { + if err := RootCmd().Execute(); err != nil { fmt.Fprintln(os.Stderr, err) } } diff --git a/cmd/token.go b/cmd/token.go new file mode 100644 index 0000000..4df1055 --- /dev/null +++ b/cmd/token.go @@ -0,0 +1,46 @@ +package cmd + +import ( + "github.com/spf13/cobra" +) + +func TokenSetJiraCmd() *cobra.Command { + return &cobra.Command{ + Use: "jira", + Short: "Sets the value of the jira token", + } +} + +func TokenSetGithubCmd() *cobra.Command { + return &cobra.Command{ + Use: "github", + Short: "Sets the value of the github token", + } +} + +func TokenSetCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "set", + Short: "Sets the value of the platform tokens", + } + + cmd.AddCommand( + TokenSetJiraCmd(), + TokenSetGithubCmd(), + ) + + return cmd +} + +func TokenCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "token", + Short: "Subcommands related to tokens", + } + + cmd.AddCommand( + TokenSetCmd(), + ) + + return cmd +}