Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions cli/cmd/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ package cmd

import (
"fmt"
"strings"

"github.com/cortexlabs/cortex/cli/types/cliconfig"
"github.com/cortexlabs/cortex/cli/types/flags"
"github.com/cortexlabs/cortex/pkg/lib/exit"
libjson "github.com/cortexlabs/cortex/pkg/lib/json"
"github.com/cortexlabs/cortex/pkg/lib/print"
"github.com/cortexlabs/cortex/pkg/lib/telemetry"
"github.com/cortexlabs/cortex/pkg/types"
Expand All @@ -45,6 +48,7 @@ func envInit() {
_envCmd.AddCommand(_envConfigureCmd)

_envListCmd.Flags().SortFlags = false
_envListCmd.Flags().VarP(&_flagOutput, "output", "o", fmt.Sprintf("output format: one of %s", strings.Join(flags.OutputTypeStrings(), "|")))
_envCmd.AddCommand(_envListCmd)

_envDefaultCmd.Flags().SortFlags = false
Expand Down Expand Up @@ -125,6 +129,15 @@ var _envListCmd = &cobra.Command{
exit.Error(err)
}

if _flagOutput == flags.JSONOutputType {
bytes, err := libjson.Marshal(cliConfig.Environments)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use MarshalIndent() here to make it look nicer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, for now -o json will not pretty print json.

if err != nil {
exit.Error(err)
}
fmt.Println(string(bytes))
return
}

defaultEnv := getDefaultEnv(_generalCommandType)

for i, env := range cliConfig.Environments {
Expand Down
17 changes: 10 additions & 7 deletions docs/miscellaneous/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,14 @@ Usage:
cortex cluster configure [flags]

Flags:
-c, --config string path to a cluster configuration file
--aws-key string aws access key id
--aws-secret string aws secret access key
-e, --env string environment to update (default "aws")
-y, --yes skip prompts
-h, --help help for configure
-c, --config string path to a cluster configuration file
--aws-key string aws access key id
--aws-secret string aws secret access key
--cluster-aws-key string aws access key id to be used by the cluster
--cluster-aws-secret string aws secret access key to be used by the cluster
-e, --env string environment to update (default "aws")
-y, --yes skip prompts
-h, --help help for configure
```

### cluster export
Expand Down Expand Up @@ -213,7 +215,8 @@ Usage:
cortex env list [flags]

Flags:
-h, --help help for list
-o, --output string output format: one of pretty|json (default "pretty")
-h, --help help for list
```

### env default
Expand Down