diff --git a/cmd/commands/datasetArchiver.go b/cmd/commands/datasetArchiver.go index 490e6fd..af9b2bb 100644 --- a/cmd/commands/datasetArchiver.go +++ b/cmd/commands/datasetArchiver.go @@ -139,7 +139,6 @@ func init() { datasetArchiverCmd.Flags().Bool("localenv", false, "Use local environment (local) instead or production") datasetArchiverCmd.Flags().Bool("devenv", false, "Use development environment instead or production") datasetArchiverCmd.Flags().Bool("noninteractive", false, "Defines if no questions will be asked, just do it - make sure you know what you are doing") - datasetArchiverCmd.Flags().Bool("version", false, "Show version number and exit") datasetArchiverCmd.MarkFlagsMutuallyExclusive("testenv", "localenv", "devenv") } diff --git a/cmd/commands/datasetCleaner.go b/cmd/commands/datasetCleaner.go index db95dba..d23e68a 100644 --- a/cmd/commands/datasetCleaner.go +++ b/cmd/commands/datasetCleaner.go @@ -118,7 +118,6 @@ func init() { datasetCleanerCmd.Flags().Bool("nonInteractive", false, "Defines if no questions will be asked, just do it - make sure you know what you are doing") datasetCleanerCmd.Flags().Bool("testenv", false, "Use test environment (qa) instead of production environment") datasetCleanerCmd.Flags().Bool("devenv", false, "Use development environment instead of production environment (developers only)") - datasetCleanerCmd.Flags().Bool("version", false, "Show version number and exit") datasetCleanerCmd.MarkFlagsMutuallyExclusive("testenv", "devenv") } diff --git a/cmd/commands/datasetGetProposal.go b/cmd/commands/datasetGetProposal.go index 8ffc39c..bda4f4d 100644 --- a/cmd/commands/datasetGetProposal.go +++ b/cmd/commands/datasetGetProposal.go @@ -107,7 +107,6 @@ func init() { datasetGetProposalCmd.Flags().String("field", "", "Defines optional field name , whose value should be returned instead of full information") datasetGetProposalCmd.Flags().Bool("testenv", false, "Use test environment (qa) instead or production") datasetGetProposalCmd.Flags().Bool("devenv", false, "Use development environment instead or production") - datasetGetProposalCmd.Flags().Bool("version", false, "Show version number and exit") datasetGetProposalCmd.MarkFlagsMutuallyExclusive("testenv", "devenv") } diff --git a/cmd/commands/datasetIngestor.go b/cmd/commands/datasetIngestor.go index 03d7cbd..e6850be 100644 --- a/cmd/commands/datasetIngestor.go +++ b/cmd/commands/datasetIngestor.go @@ -400,7 +400,6 @@ func init() { datasetIngestorCmd.Flags().Bool("allowexistingsource", false, "Defines if existing sourceFolders can be reused") datasetIngestorCmd.Flags().String("addattachment", "", "Filename of image to attach (single dataset case only)") datasetIngestorCmd.Flags().String("addcaption", "", "Optional caption to be stored with attachment (single dataset case only)") - datasetIngestorCmd.Flags().Bool("version", false, "Show version number and exit") datasetIngestorCmd.MarkFlagsMutuallyExclusive("testenv", "devenv", "localenv", "tunnelenv") } diff --git a/cmd/commands/datasetPublishData.go b/cmd/commands/datasetPublishData.go index b78ce12..009226d 100644 --- a/cmd/commands/datasetPublishData.go +++ b/cmd/commands/datasetPublishData.go @@ -337,7 +337,6 @@ func init() { // datasetPublishDataCmd.Flags().String("ownergroup", "", "Defines to publish only datasets of the specified ownerGroup") datasetPublishDataCmd.Flags().Bool("testenv", false, "Use test environment (qa) (default is to use production system)") datasetPublishDataCmd.Flags().Bool("devenv", false, "Use development environment (default is to use production system)") - datasetPublishDataCmd.Flags().Bool("version", false, "Show version number and exit") datasetPublishDataCmd.MarkFlagsMutuallyExclusive("testenv", "devenv") } diff --git a/cmd/commands/datasetPublishDataRetrieve.go b/cmd/commands/datasetPublishDataRetrieve.go index bce71f2..1124840 100644 --- a/cmd/commands/datasetPublishDataRetrieve.go +++ b/cmd/commands/datasetPublishDataRetrieve.go @@ -122,7 +122,6 @@ func init() { datasetPublishDataRetrieveCmd.Flags().String("publisheddata", "", "Defines to publish data from a given publishedData document ID") datasetPublishDataRetrieveCmd.Flags().Bool("testenv", false, "Use test environment (qa) (default is to use production system)") datasetPublishDataRetrieveCmd.Flags().Bool("devenv", false, "Use development environment (default is to use production system)") - datasetPublishDataRetrieveCmd.Flags().Bool("version", false, "Show version number and exit") datasetPublishDataRetrieveCmd.MarkFlagsMutuallyExclusive("testenv", "devenv") } diff --git a/cmd/commands/datasetRetriever.go b/cmd/commands/datasetRetriever.go index 4f51c66..744652c 100644 --- a/cmd/commands/datasetRetriever.go +++ b/cmd/commands/datasetRetriever.go @@ -216,7 +216,6 @@ func init() { datasetRetrieverCmd.Flags().String("ownergroup", "", "Defines to fetch only datasets of the specified ownerGroup (default is to fetch all available datasets)") datasetRetrieverCmd.Flags().Bool("testenv", false, "Use test environment (qa) (default is to use production system)") datasetRetrieverCmd.Flags().Bool("devenv", false, "Use development environment (default is to use production system)") - datasetRetrieverCmd.Flags().Bool("version", false, "Show version number and exit") datasetRetrieverCmd.MarkFlagsMutuallyExclusive("testenv", "devenv") } diff --git a/cmd/commands/root.go b/cmd/commands/root.go index 1f4f822..97d7e7e 100644 --- a/cmd/commands/root.go +++ b/cmd/commands/root.go @@ -1,6 +1,7 @@ package cmd import ( + "fmt" "os" "github.com/spf13/cobra" @@ -12,8 +13,15 @@ var rootCmd = &cobra.Command{ Long: `This library comprises a few subcommands for managing SciCat and datasets on it, as well as interacting with the archival system connected to it.`, - // uncomment the next line if there's a default action - // Run: func(cmd *cobra.Command, args []string) { }, + Run: func(cmd *cobra.Command, args []string) { + version, _ := cmd.Flags().GetBool("version") + if version { + fmt.Printf("%s\n", VERSION) + return + } + fmt.Print("No action was specified.\n\n") + cmd.Help() + }, } func Execute() { @@ -29,4 +37,5 @@ func init() { rootCmd.PersistentFlags().StringP("user", "u", "", "Defines optional username:password string") rootCmd.PersistentFlags().String("token", "", "Defines optional API token instead of username:password") rootCmd.PersistentFlags().StringP("config", "c", "", "A path to a config file for connecting to SciCat and transfer services") + rootCmd.PersistentFlags().BoolP("version", "v", false, "Show version") } diff --git a/cmd/commands/waitForJobFinished.go b/cmd/commands/waitForJobFinished.go index f388b2d..3c74e0e 100644 --- a/cmd/commands/waitForJobFinished.go +++ b/cmd/commands/waitForJobFinished.go @@ -171,7 +171,6 @@ func init() { waitForJobFinishedCmd.Flags().String("job", "", "Defines the job id to poll") waitForJobFinishedCmd.Flags().Bool("testenv", false, "Use test environment (qa) instead or production") waitForJobFinishedCmd.Flags().Bool("devenv", false, "Use development environment instead or production") - waitForJobFinishedCmd.Flags().Bool("version", false, "Show version number and exit") waitForJobFinishedCmd.MarkFlagsMutuallyExclusive("testenv", "devenv") }