Skip to content

Commit

Permalink
Merge pull request #10 from DopplerHQ/tom_short_flags
Browse files Browse the repository at this point in the history
Support short flags for key, project, and config
  • Loading branch information
Piccirello authored Nov 15, 2019
2 parents ed110b3 + 53ec1d1 commit bf92cc3
Show file tree
Hide file tree
Showing 16 changed files with 97 additions and 97 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Warning: This tool is current pre-release. For the current stable version, please use the [node-cli](https://github.com/DopplerHQ/node-cli).

The Doppler CLI is the official tool for interacting with your Doppler secrets and configuration.
The Doppler CLI is the official tool for interacting with your Enclave secrets and configuration.

**You can:**

Expand Down Expand Up @@ -112,11 +112,11 @@ Here's an example Dockerfile showing how you can build on top of Doppler's base
FROM dopplerhq/cli:node

# doppler args are passed at runtime
ENV DOPPLER_API_KEY="" DOPPLER_PROJECT="" DOPPLER_CONFIG=""
ENV DOPPLER_TOKEN="" DOPPLER_PROJECT="" DOPPLER_CONFIG=""

COPY . .

ENTRYPOINT doppler run --key="$DOPPLER_API_KEY" --project="$DOPPLER_PROJECT" --config="$DOPPLER_CONFIG" -- node index.js
ENTRYPOINT doppler run --token="$DOPPLER_TOKEN" --project="$DOPPLER_PROJECT" --config="$DOPPLER_CONFIG" -- node index.js
```

### Other
Expand All @@ -130,12 +130,12 @@ You can also directly download the generated `.deb` and `.rpm` packages. If a bi
Once installed, you can access the Doppler CLI with the `doppler` command.

```sh
$ doppler configure set key=$YOUR_API_KEY # set local credentials
$ doppler configure set token=$YOUR_TOKEN # set local credentials
$ doppler setup # select your project and config
$ doppler configure --all # (optional) view local configuration
```

The first command will save your api key to the local configuration file, and it will be scoped to the current directory. You can modify this scope by specifying the `--scope` flag. See `doppler help configure set` for more info, or run `doppler configure --all` to view your current configuration.
The first command will save your api token to the local configuration file, and it will be scoped to the current directory. You can modify this scope by specifying the `--scope` flag. See `doppler help configure set` for more info, or run `doppler configure --all` to view your current configuration.

For a list of all commands:

Expand Down Expand Up @@ -189,7 +189,7 @@ Note: The release will automatically fail if the tag and HEAD have diverged:

#### Generate a GPG key

Store the keys and passphrase in your doppler config
Store the keys and passphrase in your enclave config

```
$ gpg --full-generate-key
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/activity.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var activityCmd = &cobra.Command{
localConfig := configuration.LocalConfig(cmd)
number := utils.GetIntFlag(cmd, "number", 16)

_, activity := api.GetAPIActivityLogs(cmd, localConfig.APIHost.Value, localConfig.Key.Value)
_, activity := api.GetAPIActivityLogs(cmd, localConfig.APIHost.Value, localConfig.Token.Value)

utils.PrintLogs(activity, number, jsonFlag)
},
Expand All @@ -50,7 +50,7 @@ var activityGetCmd = &cobra.Command{
log = args[0]
}

_, activity := api.GetAPIActivityLog(cmd, localConfig.APIHost.Value, localConfig.Key.Value, log)
_, activity := api.GetAPIActivityLog(cmd, localConfig.APIHost.Value, localConfig.Token.Value, log)

utils.PrintLog(activity, jsonFlag)
},
Expand Down
46 changes: 23 additions & 23 deletions pkg/cmd/configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var configsCmd = &cobra.Command{
jsonFlag := utils.JSON
localConfig := configuration.LocalConfig(cmd)

_, configs := api.GetAPIConfigs(cmd, localConfig.APIHost.Value, localConfig.Key.Value, localConfig.Project.Value)
_, configs := api.GetAPIConfigs(cmd, localConfig.APIHost.Value, localConfig.Token.Value, localConfig.Project.Value)

utils.PrintConfigsInfo(configs, jsonFlag)
},
Expand All @@ -54,7 +54,7 @@ var configsGetCmd = &cobra.Command{
config = args[0]
}

_, configInfo := api.GetAPIConfig(cmd, localConfig.APIHost.Value, localConfig.Key.Value, localConfig.Project.Value, config)
_, configInfo := api.GetAPIConfig(cmd, localConfig.APIHost.Value, localConfig.Token.Value, localConfig.Project.Value, config)

utils.PrintConfigInfo(configInfo, jsonFlag)
},
Expand All @@ -76,7 +76,7 @@ var configsCreateCmd = &cobra.Command{
}

localConfig := configuration.LocalConfig(cmd)
_, info := api.CreateAPIConfig(cmd, localConfig.APIHost.Value, localConfig.Key.Value, localConfig.Project.Value, name, environment, defaults)
_, info := api.CreateAPIConfig(cmd, localConfig.APIHost.Value, localConfig.Token.Value, localConfig.Project.Value, name, environment, defaults)

if !silent {
utils.PrintConfigInfo(info, jsonFlag)
Expand All @@ -100,10 +100,10 @@ var configsDeleteCmd = &cobra.Command{
}

if yes || utils.ConfirmationPrompt("Delete config "+config) {
api.DeleteAPIConfig(cmd, localConfig.APIHost.Value, localConfig.Key.Value, localConfig.Project.Value, config)
api.DeleteAPIConfig(cmd, localConfig.APIHost.Value, localConfig.Token.Value, localConfig.Project.Value, config)

if !silent {
_, configs := api.GetAPIConfigs(cmd, localConfig.APIHost.Value, localConfig.Key.Value, localConfig.Project.Value)
_, configs := api.GetAPIConfigs(cmd, localConfig.APIHost.Value, localConfig.Token.Value, localConfig.Project.Value)
utils.PrintConfigsInfo(configs, jsonFlag)
}
}
Expand All @@ -125,7 +125,7 @@ var configsUpdateCmd = &cobra.Command{
config = args[0]
}

_, info := api.UpdateAPIConfig(cmd, localConfig.APIHost.Value, localConfig.Key.Value, localConfig.Project.Value, config, name)
_, info := api.UpdateAPIConfig(cmd, localConfig.APIHost.Value, localConfig.Token.Value, localConfig.Project.Value, config, name)

if !silent {
utils.PrintConfigInfo(info, jsonFlag)
Expand All @@ -142,7 +142,7 @@ var configsLogsCmd = &cobra.Command{
localConfig := configuration.LocalConfig(cmd)
number := utils.GetIntFlag(cmd, "number", 16)

_, logs := api.GetAPIConfigLogs(cmd, localConfig.APIHost.Value, localConfig.Key.Value, localConfig.Project.Value, localConfig.Config.Value)
_, logs := api.GetAPIConfigLogs(cmd, localConfig.APIHost.Value, localConfig.Token.Value, localConfig.Project.Value, localConfig.Config.Value)

utils.PrintLogs(logs, number, jsonFlag)
},
Expand All @@ -161,7 +161,7 @@ var configsLogsGetCmd = &cobra.Command{
log = args[0]
}

_, configLog := api.GetAPIConfigLog(cmd, localConfig.APIHost.Value, localConfig.Key.Value, localConfig.Project.Value, localConfig.Config.Value, log)
_, configLog := api.GetAPIConfigLog(cmd, localConfig.APIHost.Value, localConfig.Token.Value, localConfig.Project.Value, localConfig.Config.Value, log)

// TODO print diff (like node cli environments:logs:view command)
utils.PrintLog(configLog, jsonFlag)
Expand All @@ -182,7 +182,7 @@ var configsLogsRollbackCmd = &cobra.Command{
log = args[0]
}

_, configLog := api.RollbackAPIConfigLog(cmd, localConfig.APIHost.Value, localConfig.Key.Value, localConfig.Project.Value, localConfig.Config.Value, log)
_, configLog := api.RollbackAPIConfigLog(cmd, localConfig.APIHost.Value, localConfig.Token.Value, localConfig.Project.Value, localConfig.Config.Value, log)

if !silent {
// TODO print diff (like node cli environments:logs:view command)
Expand All @@ -192,46 +192,46 @@ var configsLogsRollbackCmd = &cobra.Command{
}

func init() {
configsCmd.Flags().String("project", "", "doppler project (e.g. backend)")
configsCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)")

configsGetCmd.Flags().String("project", "", "doppler project (e.g. backend)")
configsGetCmd.Flags().String("config", "", "doppler config (e.g. dev)")
configsGetCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)")
configsGetCmd.Flags().StringP("config", "c", "", "enclave config (e.g. dev)")
configsCmd.AddCommand(configsGetCmd)

configsCreateCmd.Flags().String("project", "", "doppler project (e.g. backend)")
configsCreateCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)")
configsCreateCmd.Flags().String("name", "", "config name")
configsCreateCmd.Flags().String("environment", "", "config environment")
configsCreateCmd.Flags().Bool("defaults", true, "populate config with environment's default secrets")
configsCreateCmd.Flags().Bool("silent", false, "don't output the response")
configsCreateCmd.MarkFlagRequired("environment")
configsCmd.AddCommand(configsCreateCmd)

configsUpdateCmd.Flags().String("project", "", "doppler project (e.g. backend)")
configsUpdateCmd.Flags().String("config", "", "doppler config (e.g. dev)")
configsUpdateCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)")
configsUpdateCmd.Flags().StringP("config", "c", "", "enclave config (e.g. dev)")
configsUpdateCmd.Flags().String("name", "", "config name")
configsUpdateCmd.Flags().Bool("silent", false, "don't output the response")
configsUpdateCmd.MarkFlagRequired("name")
configsCmd.AddCommand(configsUpdateCmd)

configsDeleteCmd.Flags().String("project", "", "doppler project (e.g. backend)")
configsDeleteCmd.Flags().String("config", "", "doppler config (e.g. dev)")
configsDeleteCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)")
configsDeleteCmd.Flags().StringP("config", "c", "", "enclave config (e.g. dev)")
configsDeleteCmd.Flags().Bool("silent", false, "don't output the response")
configsDeleteCmd.Flags().Bool("yes", false, "proceed without confirmation")
configsCmd.AddCommand(configsDeleteCmd)

configsLogsCmd.Flags().String("project", "", "doppler project (e.g. backend)")
configsLogsCmd.Flags().String("config", "", "doppler config (e.g. dev)")
configsLogsCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)")
configsLogsCmd.Flags().StringP("config", "c", "", "enclave config (e.g. dev)")
configsLogsCmd.Flags().IntP("number", "n", 5, "max number of logs to display")
configsCmd.AddCommand(configsLogsCmd)

configsLogsGetCmd.Flags().String("log", "", "audit log id")
configsLogsGetCmd.Flags().String("project", "", "doppler project (e.g. backend)")
configsLogsGetCmd.Flags().String("config", "", "doppler config (e.g. dev)")
configsLogsGetCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)")
configsLogsGetCmd.Flags().StringP("config", "c", "", "enclave config (e.g. dev)")
configsLogsCmd.AddCommand(configsLogsGetCmd)

configsLogsRollbackCmd.Flags().String("log", "", "audit log id")
configsLogsRollbackCmd.Flags().String("project", "", "doppler project (e.g. backend)")
configsLogsRollbackCmd.Flags().String("config", "", "doppler config (e.g. dev)")
configsLogsRollbackCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)")
configsLogsRollbackCmd.Flags().StringP("config", "c", "", "enclave config (e.g. dev)")
configsLogsRollbackCmd.Flags().Bool("silent", false, "don't output the response")
configsLogsCmd.AddCommand(configsLogsRollbackCmd)

Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ var configureCmd = &cobra.Command{
if jsonFlag {
confMap := make(map[string]map[string]string)

if config.Key != (models.Pair{}) {
storeInMap(&confMap, "key", config.Key)
if config.Token != (models.Pair{}) {
storeInMap(&confMap, "token", config.Token)
}

if config.Project != (models.Pair{}) {
Expand Down
6 changes: 3 additions & 3 deletions pkg/cmd/environments.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var environmentsCmd = &cobra.Command{
project = args[0]
}

_, info := api.GetAPIEnvironments(cmd, localConfig.APIHost.Value, localConfig.Key.Value, project)
_, info := api.GetAPIEnvironments(cmd, localConfig.APIHost.Value, localConfig.Token.Value, project)

utils.PrintEnvironmentsInfo(info, jsonFlag)
},
Expand All @@ -50,14 +50,14 @@ var environmentsGetCmd = &cobra.Command{
localConfig := configuration.LocalConfig(cmd)
environment := args[0]

_, info := api.GetAPIEnvironment(cmd, localConfig.APIHost.Value, localConfig.Key.Value, localConfig.Project.Value, environment)
_, info := api.GetAPIEnvironment(cmd, localConfig.APIHost.Value, localConfig.Token.Value, localConfig.Project.Value, environment)

utils.PrintEnvironmentInfo(info, jsonFlag)
},
}

func init() {
environmentsGetCmd.Flags().String("project", "", "output json")
environmentsGetCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)")
environmentsCmd.AddCommand(environmentsGetCmd)

rootCmd.AddCommand(environmentsCmd)
Expand Down
18 changes: 9 additions & 9 deletions pkg/cmd/projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var projectsCmd = &cobra.Command{
jsonFlag := utils.JSON

localConfig := configuration.LocalConfig(cmd)
_, info := api.GetAPIProjects(cmd, localConfig.APIHost.Value, localConfig.Key.Value)
_, info := api.GetAPIProjects(cmd, localConfig.APIHost.Value, localConfig.Token.Value)

utils.PrintProjectsInfo(info, jsonFlag)
},
Expand All @@ -49,7 +49,7 @@ var projectsGetCmd = &cobra.Command{
project = args[0]
}

_, info := api.GetAPIProject(cmd, localConfig.APIHost.Value, localConfig.Key.Value, project)
_, info := api.GetAPIProject(cmd, localConfig.APIHost.Value, localConfig.Token.Value, project)

utils.PrintProjectInfo(info, jsonFlag)
},
Expand All @@ -70,7 +70,7 @@ var projectsCreateCmd = &cobra.Command{
}

localConfig := configuration.LocalConfig(cmd)
_, info := api.CreateAPIProject(cmd, localConfig.APIHost.Value, localConfig.Key.Value, name, description)
_, info := api.CreateAPIProject(cmd, localConfig.APIHost.Value, localConfig.Token.Value, name, description)

if !silent {
utils.PrintProjectInfo(info, jsonFlag)
Expand All @@ -94,10 +94,10 @@ var projectsDeleteCmd = &cobra.Command{
}

if yes || utils.ConfirmationPrompt("Delete project "+project) {
api.DeleteAPIProject(cmd, localConfig.APIHost.Value, localConfig.Key.Value, project)
api.DeleteAPIProject(cmd, localConfig.APIHost.Value, localConfig.Token.Value, project)

if !silent {
_, info := api.GetAPIProjects(cmd, localConfig.APIHost.Value, localConfig.Key.Value)
_, info := api.GetAPIProjects(cmd, localConfig.APIHost.Value, localConfig.Token.Value)
utils.PrintProjectsInfo(info, jsonFlag)
}
}
Expand All @@ -121,7 +121,7 @@ var projectsUpdateCmd = &cobra.Command{
name := cmd.Flag("name").Value.String()
description := cmd.Flag("description").Value.String()

_, info := api.UpdateAPIProject(cmd, localConfig.APIHost.Value, localConfig.Key.Value, project, name, description)
_, info := api.UpdateAPIProject(cmd, localConfig.APIHost.Value, localConfig.Token.Value, project, name, description)

if !silent {
utils.PrintProjectInfo(info, jsonFlag)
Expand All @@ -130,7 +130,7 @@ var projectsUpdateCmd = &cobra.Command{
}

func init() {
projectsGetCmd.Flags().String("project", "", "doppler project (e.g. backend)")
projectsGetCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)")
projectsCmd.AddCommand(projectsGetCmd)

projectsCreateCmd.Flags().Bool("silent", false, "don't output the response")
Expand All @@ -140,11 +140,11 @@ func init() {

projectsDeleteCmd.Flags().Bool("silent", false, "don't output the response")
projectsDeleteCmd.Flags().Bool("yes", false, "proceed without confirmation")
projectsDeleteCmd.Flags().String("project", "", "doppler project (e.g. backend)")
projectsDeleteCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)")
projectsCmd.AddCommand(projectsDeleteCmd)

projectsUpdateCmd.Flags().Bool("silent", false, "don't output the response")
projectsUpdateCmd.Flags().String("project", "", "doppler project (e.g. backend)")
projectsUpdateCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)")
projectsUpdateCmd.Flags().String("name", "", "project name")
projectsUpdateCmd.Flags().String("description", "", "project description")
projectsUpdateCmd.MarkFlagRequired("name")
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ func init() {
rootCmd.Version = version.ProgramVersion
rootCmd.SetVersionTemplate(rootCmd.Version + "\n")

rootCmd.PersistentFlags().String("key", "", "doppler api key")
rootCmd.PersistentFlags().StringP("token", "t", "", "doppler token")
rootCmd.PersistentFlags().String("api-host", "https://api.doppler.com", "api host")
rootCmd.PersistentFlags().String("deploy-host", "https://deploy.doppler.com", "deploy host")
rootCmd.PersistentFlags().Bool("insecure", false, "support TLS connections with invalid certificate")

rootCmd.PersistentFlags().Bool("no-read-env", false, "don't read doppler config from the environment")
rootCmd.PersistentFlags().Bool("no-read-env", false, "don't read enclave config from the environment")
rootCmd.PersistentFlags().String("scope", ".", "the directory to scope your config to")
rootCmd.PersistentFlags().String("configuration", configuration.ConfigFile, "config file")
rootCmd.PersistentFlags().Bool("json", false, "output json")
Expand Down
6 changes: 3 additions & 3 deletions pkg/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func getSecrets(cmd *cobra.Command, localConfig models.ScopedConfig, fallbackPat
return readFallbackFile(fallbackPath)
}

response, err := api.GetDeploySecrets(cmd, localConfig.DeployHost.Value, localConfig.Key.Value, localConfig.Project.Value, localConfig.Config.Value)
response, err := api.GetDeploySecrets(cmd, localConfig.DeployHost.Value, localConfig.Token.Value, localConfig.Project.Value, localConfig.Config.Value)

if !useFallbackFile && err != nil {
utils.Err(err)
Expand Down Expand Up @@ -128,8 +128,8 @@ func readFallbackFile(path string) map[string]string {
}

func init() {
runCmd.Flags().String("project", "", "doppler project (e.g. backend)")
runCmd.Flags().String("config", "", "doppler config (e.g. dev)")
runCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)")
runCmd.Flags().StringP("config", "c", "", "enclave config (e.g. dev)")

runCmd.Flags().String("fallback", "", "write secrets to this file after connecting to Doppler. secrets will be read from this file if future connection attempts are unsuccessful.")
runCmd.Flags().Bool("fallback-readonly", false, "don't update or modify the fallback file")
Expand Down
Loading

0 comments on commit bf92cc3

Please sign in to comment.