in cli/azd/cmd/config.go [30:173]
func configActions(root *actions.ActionDescriptor, rootOptions *internal.GlobalCommandOptions) *actions.ActionDescriptor {
userConfigDir, err := config.GetUserConfigDir()
if rootOptions.GenerateStaticHelp {
userConfigPath = heredoc.Doc(`the configuration path.
The default value of the config directory is:
* ` + output.WithBackticks(`$HOME/.azd`) + ` on Linux and macOS
* ` + output.WithBackticks(`%USERPROFILE%\.azd`) + ` on Windows
The configuration directory can be overridden by specifying a path in the AZD_CONFIG_DIR environment variable`)
} else if err != nil {
userConfigPath = output.WithBackticks(filepath.Join("$AZURE_CONFIG_DIR", "config.json"))
} else {
userConfigPath = output.WithBackticks(filepath.Join(userConfigDir, "config.json"))
}
var defaultConfigPath string
if runtime.GOOS == "windows" {
defaultConfigPath = filepath.Join("%USERPROFILE%", ".azd")
} else {
defaultConfigPath = filepath.Join("$HOME", ".azd")
}
var helpConfigPaths string
if rootOptions.GenerateStaticHelp {
//nolint:lll
helpConfigPaths = heredoc.Doc(`
Available since ` + output.WithBackticks("azure-dev-cli_0.4.0-beta.1") + `.
The easiest way to configure ` + output.WithBackticks("azd") + ` for the first time is to run [` + output.WithBackticks("azd init") + `](#azd-init). The subscription and location you select will be stored in the ` + output.WithBackticks("config.json") + ` file located in the config directory. To configure ` + output.WithBackticks("azd") + ` anytime afterwards, you'll use [` + output.WithBackticks("azd config set") + `](#azd-config-set).
The default value of the config directory is:
* $HOME/.azd on Linux and macOS
* %USERPROFILE%\.azd on Windows
`)
} else {
helpConfigPaths = heredoc.Docf(`
The easiest way to initially configure azd is to run %s.
The subscription and location you select will be stored at %s.
The default configuration path is %s.`,
output.WithBackticks("azd init"),
userConfigPath,
output.WithBackticks(defaultConfigPath))
}
longDescription := heredoc.Docf(`
Manage the Azure Developer CLI user configuration, which includes your default Azure subscription and location.
%s
The configuration directory can be overridden by specifying a path in the AZD_CONFIG_DIR environment variable.`,
helpConfigPaths)
group := root.Add("config", &actions.ActionDescriptorOptions{
Command: &cobra.Command{
Use: "config",
Short: "Manage azd configurations (ex: default Azure subscription, location).",
Long: longDescription,
},
HelpOptions: actions.ActionHelpOptions{
Description: getCmdConfigHelpDescription,
Footer: getCmdConfigHelpFooter,
},
GroupingOptions: actions.CommandGroupOptions{
RootLevelHelp: actions.CmdGroupConfig,
},
})
group.Add("show", &actions.ActionDescriptorOptions{
Command: &cobra.Command{
Short: "Show all the configuration values.",
Long: `Show all configuration values in ` + userConfigPath + `.`,
},
ActionResolver: newConfigShowAction,
OutputFormats: []output.Format{output.JsonFormat},
DefaultFormat: output.JsonFormat,
})
group.Add("list", &actions.ActionDescriptorOptions{
Command: &cobra.Command{
Short: "List all the configuration values. (Deprecated. Use azd config show)",
Hidden: true,
},
ActionResolver: newConfigListAction,
OutputFormats: []output.Format{output.JsonFormat},
DefaultFormat: output.JsonFormat,
})
group.Add("get", &actions.ActionDescriptorOptions{
Command: &cobra.Command{
Use: "get <path>",
Short: "Gets a configuration.",
Long: `Gets a configuration in ` + userConfigPath + `.`,
Args: cobra.ExactArgs(1),
},
ActionResolver: newConfigGetAction,
OutputFormats: []output.Format{output.JsonFormat},
DefaultFormat: output.JsonFormat,
})
group.Add("set", &actions.ActionDescriptorOptions{
Command: &cobra.Command{
Use: "set <path> <value>",
Short: "Sets a configuration.",
Long: `Sets a configuration in ` + userConfigPath + `.`,
Args: cobra.ExactArgs(2),
Example: `$ azd config set defaults.subscription <yourSubscriptionID>
$ azd config set defaults.location eastus`,
},
ActionResolver: newConfigSetAction,
})
group.Add("unset", &actions.ActionDescriptorOptions{
Command: &cobra.Command{
Use: "unset <path>",
Short: "Unsets a configuration.",
Long: `Removes a configuration in ` + userConfigPath + `.`,
Example: `$ azd config unset defaults.location`,
Args: cobra.ExactArgs(1),
},
ActionResolver: newConfigUnsetAction,
})
group.Add("reset", &actions.ActionDescriptorOptions{
Command: &cobra.Command{
Short: "Resets configuration to default.",
Long: `Resets all configuration in ` + userConfigPath + ` to the default.`,
},
ActionResolver: newConfigResetAction,
FlagsResolver: newConfigResetFlags,
})
group.Add("list-alpha", &actions.ActionDescriptorOptions{
Command: &cobra.Command{
Short: "Display the list of available features in alpha stage.",
},
HelpOptions: actions.ActionHelpOptions{
Footer: getCmdListAlphaHelpFooter,
},
ActionResolver: newConfigListAlphaAction,
})
return group
}