From 390d1d0a9118497ffd53a60117b19da5e42cd337 Mon Sep 17 00:00:00 2001 From: Arjun Aditya Date: Thu, 26 Sep 2024 17:25:43 +0530 Subject: [PATCH] feat: alias for import-project --- src/cmd/projectImport.go | 3 ++- src/cmdBuilder/buildCobraCmd.go | 1 + src/cmdBuilder/cmd.go | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/cmd/projectImport.go b/src/cmd/projectImport.go index fd8d121..386a3b4 100644 --- a/src/cmd/projectImport.go +++ b/src/cmd/projectImport.go @@ -19,7 +19,8 @@ const defaultYamlFilePattern = "*import.yml" func projectImportCmd() *cmdBuilder.Cmd { return cmdBuilder.NewCmd(). - Use("import"). + Use("import-project"). + Aliases("import"). Short(i18n.T(i18n.CmdDescProjectImport)). Long(i18n.T(i18n.CmdDescProjectImportLong)). StringFlag("orgId", "", i18n.T(i18n.OrgIdFlag)). diff --git a/src/cmdBuilder/buildCobraCmd.go b/src/cmdBuilder/buildCobraCmd.go index 99be820..4dedee2 100644 --- a/src/cmdBuilder/buildCobraCmd.go +++ b/src/cmdBuilder/buildCobraCmd.go @@ -20,6 +20,7 @@ func buildCobraCmd( Short: cmd.short, SilenceUsage: cmd.silenceUsage, SilenceErrors: cmd.silenceError, + Aliases: cmd.aliases, } if cmd.helpTemplate != "" { diff --git a/src/cmdBuilder/cmd.go b/src/cmdBuilder/cmd.go index 4d4a7f6..008a0fa 100644 --- a/src/cmdBuilder/cmd.go +++ b/src/cmdBuilder/cmd.go @@ -14,6 +14,7 @@ type ScopeLevel interface { type Cmd struct { use string + aliases []string short string long string helpTemplate string @@ -60,6 +61,11 @@ func (cmd *Cmd) Use(use string) *Cmd { return cmd } +func (cmd *Cmd) Aliases(aliases ...string) *Cmd { + cmd.aliases = aliases + return cmd +} + func (cmd *Cmd) SetHelpTemplate(template string) *Cmd { cmd.helpTemplate = template return cmd