cmd/config.go
changeset 114 590c9dd7328e
parent 113 2e411da68fd3
child 127 2b4d0f198a94
equal deleted inserted replaced
113:2e411da68fd3 114:590c9dd7328e
     6 package cmd
     6 package cmd
     7 
     7 
     8 import (
     8 import (
     9 	"os"
     9 	"os"
    10 
    10 
       
    11 	"github.com/mattn/go-isatty"
    11 	"github.com/spf13/cobra"
    12 	"github.com/spf13/cobra"
    12 	"github.com/spf13/viper"
    13 	"github.com/spf13/viper"
    13 
    14 
    14 	"github.com/McKael/madonctl/printer"
    15 	"github.com/McKael/madonctl/printer"
    15 )
    16 )
    87 	if getOutputFormat() == "plain" {
    88 	if getOutputFormat() == "plain" {
    88 		cfile := viper.ConfigFileUsed()
    89 		cfile := viper.ConfigFileUsed()
    89 		if cfile == "" {
    90 		if cfile == "" {
    90 			cfile = defaultConfigFile
    91 			cfile = defaultConfigFile
    91 		}
    92 		}
    92 		errPrint("You can copy the following lines into a configuration file.")
    93 		if isatty.IsTerminal(os.Stdout.Fd()) {
    93 		errPrint("E.g. %s -i INSTANCE -L USERNAME -P PASS config dump > %s", AppName, cfile)
    94 			errPrint("You can copy the following lines into a configuration file.")
    94 		errPrint(" or  %s -i INSTANCE oauth2 > %s\n", AppName, cfile)
    95 			errPrint("E.g. %s -i INSTANCE -L USERNAME -P PASS config dump > %s", AppName, cfile)
       
    96 			errPrint(" or  %s -i INSTANCE oauth2 > %s\n", AppName, cfile)
       
    97 		}
    95 		pOptions := printer.Options{"template": configurationTemplate}
    98 		pOptions := printer.Options{"template": configurationTemplate}
    96 		p, err = printer.NewPrinterTemplate(pOptions)
    99 		p, err = printer.NewPrinterTemplate(pOptions)
    97 	} else {
   100 	} else {
    98 		p, err = getPrinter()
   101 		p, err = getPrinter()
    99 	}
   102 	}