-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added version command. Stage from context for migration command is re…
…ceived as Interface. Introduced CommandContextKey type for command context receiving.
- Loading branch information
1 parent
3fa3059
commit c06ef6e
Showing
5 changed files
with
57 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package commands | ||
|
||
type CommandContextKey string | ||
|
||
const ( | ||
CommandContextCfgKeyOverall CommandContextKey = "cfg" | ||
CommandContextCfgKeyDB = CommandContextCfgKeyOverall + ".db" | ||
CommandContextCfgKeyLog = CommandContextCfgKeyOverall + ".log" | ||
CommandContextCfgKeyAppInfo = CommandContextCfgKeyOverall + ".appInfo" | ||
CommandContextCfgKeyStage = CommandContextCfgKeyOverall + ".stage" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package commands | ||
|
||
import ( | ||
"fmt" | ||
|
||
cfgstructs "github.com/spacetab-io/configuration-structs-go" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var VersionCmd = &cobra.Command{ | ||
Use: "version", | ||
Short: "Print the version number", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
appInfo, ok := cmd.Context().Value(CommandContextCfgKeyAppInfo).(cfgstructs.ApplicationInfoCfgInterface) | ||
if !ok { | ||
return fmt.Errorf("%w: app info config (cfg.appInfo)", ErrBadContextValue) | ||
} | ||
|
||
cmd.Println(appInfo.GetVersion()) | ||
|
||
return nil | ||
}, | ||
} |