Skip to content

Commit

Permalink
Merge pull request #117 from dinusha92/3.0.0-beta
Browse files Browse the repository at this point in the history
Fixing issue in init command.
  • Loading branch information
dinusha92 authored Oct 13, 2019
2 parents 94550a7 + 240edee commit 2637328
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions import-export-cli/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,21 @@ const RootCmdShortDesc = "CLI for Importing and Exporting APIs and Applications"
const RootCmdLongDesc = utils.ProjectName + ` is a Command Line Tool for Importing and Exporting APIs and Applications between different environments of WSO2 API Manager
(Dev, Production, Staging, QA etc.)`


//Get config to check mode
var configVars = utils.GetMainConfigFromFile(utils.MainConfigFilePath)

// This represents the base command when called without any subcommands
var RootCmd = &cobra.Command{
Use: utils.ProjectName,
Args: func(cmd *cobra.Command, args []string) error {
if configVars.Config.KubernetesMode {
if isK8sEnabled() {
return cobra.ArbitraryArgs(cmd, args)
} else {
return cobra.NoArgs(cmd, args)
}
},
DisableFlagParsing: setDisableFlagParsing(),
DisableFlagParsing: isK8sEnabled(),
Short: RootCmdShortDesc,
Long: RootCmdLongDesc,
Run: func(cmd *cobra.Command, args []string) {
if configVars.Config.KubernetesMode {
if isK8sEnabled() {
executeKubernetes(args...)
} else {
cmd.Help()
Expand Down Expand Up @@ -186,9 +182,9 @@ func initConfig() {
}

//disable flags when the mode set to kubernetes
func setDisableFlagParsing() bool {
func isK8sEnabled() bool {
//Get config to check mode
configVars = utils.GetMainConfigFromFileSilently(utils.MainConfigFilePath)
configVars := utils.GetMainConfigFromFileSilently(utils.MainConfigFilePath)
if configVars != nil && configVars.Config.KubernetesMode {
return true
} else {
Expand All @@ -209,4 +205,4 @@ func executeKubernetes(arg ...string) {
if err != nil {
utils.HandleErrorAndExit("Error executing kubernetes commands ", err)
}
}
}

0 comments on commit 2637328

Please sign in to comment.