From b4e85736346371a66803981680194a295e18e661 Mon Sep 17 00:00:00 2001 From: "M. Mert Yildiran" Date: Thu, 6 Jul 2023 21:57:21 +0300 Subject: [PATCH] :sparkles: Add `license` command --- cmd/license.go | 21 +++++++++++++++++++++ config/config.go | 2 ++ 2 files changed, 23 insertions(+) create mode 100644 cmd/license.go diff --git a/cmd/license.go b/cmd/license.go new file mode 100644 index 000000000..6bdb63758 --- /dev/null +++ b/cmd/license.go @@ -0,0 +1,21 @@ +package cmd + +import ( + "fmt" + + "github.com/kubeshark/kubeshark/config" + "github.com/spf13/cobra" +) + +var licenseCmd = &cobra.Command{ + Use: "license", + Short: "Print the license loaded string", + RunE: func(cmd *cobra.Command, args []string) error { + fmt.Println(config.Config.License) + return nil + }, +} + +func init() { + rootCmd.AddCommand(licenseCmd) +} diff --git a/config/config.go b/config/config.go index c4c37a9a1..69c4e439e 100644 --- a/config/config.go +++ b/config/config.go @@ -56,6 +56,7 @@ func InitConfig(cmd *cobra.Command) error { "console", "pro", "manifests", + "license", }, cmd.Use) { go version.CheckNewerVersion() } @@ -80,6 +81,7 @@ func InitConfig(cmd *cobra.Command) error { ConfigFilePath = path.Join(misc.GetDotFolderPath(), "config.yaml") if err := loadConfigFile(&Config, utils.Contains([]string{ "manifests", + "license", }, cmd.Use)); err != nil { if !os.IsNotExist(err) { return fmt.Errorf("invalid config, %w\n"+