Ejemplo n.º 1
0
func configCmd(c *cli.Context) {
	if len(c.Args()) > 1 {
		cliutils.Exit(cliutils.ExitCodeError, "Wrong number of arguments. "+cliutils.GetDocumentationMessage())
	} else if len(c.Args()) == 1 {
		if c.Args()[0] == "show" {
			commands.ShowConfig()
		} else if c.Args()[0] == "clear" {
			commands.ClearConfig()
		} else {
			cliutils.Exit(cliutils.ExitCodeError, "Unknown argument '"+c.Args()[0]+"'. Available arguments are 'show' and 'clear'.")
		}
	} else {
		configFlags, err := createConfigFlags(c)
		cliutils.ExitOnErr(err)
		_, err = commands.Config(configFlags.ArtDetails, nil, configFlags.Interactive, configFlags.EncPassword)
		cliutils.ExitOnErr(err)
	}
}
Ejemplo n.º 2
0
func offerConfig(c *cli.Context) (details *config.ArtifactoryDetails, err error) {
	var exists bool
	exists, err = config.IsArtifactoryConfExists()
	if err != nil {
		return
	}
	if exists {
		return
	}
	var val bool
	val, err = cliutils.GetBoolEnvValue("JFROG_CLI_OFFER_CONFIG", true)
	if err != nil {
		return
	}
	if !val {
		config.SaveArtifactoryConf(new(config.ArtifactoryDetails))
		return
	}
	msg := "The CLI commands require the Artifactory URL and authentication details\n" +
		"Configuring JFrog CLI with these parameters now will save you having to include them as command options.\n" +
		"You can also configure these parameters later using the 'config' command.\n" +
		"Configure now? (y/n): "
	fmt.Print(msg)
	var confirm string
	fmt.Scanln(&confirm)
	if !cliutils.ConfirmAnswer(confirm) {
		config.SaveArtifactoryConf(new(config.ArtifactoryDetails))
		return
	}
	details, err = createArtifactoryDetails(c, false)
	if err != nil {
		return
	}
	encPassword := cliutils.GetBoolFlagValue(c, "enc-password", true)
	details, err = commands.Config(nil, details, true, encPassword)
	return
}