Skip to content

Commit e8edbcc

Browse files
authored
CLI UI improvements (#1007)
1 parent 73fdf02 commit e8edbcc

File tree

9 files changed

+13
-15
lines changed

9 files changed

+13
-15
lines changed

cli/cmd/cluster.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"github.com/cortexlabs/cortex/cli/types/cliconfig"
2929
"github.com/cortexlabs/cortex/pkg/lib/aws"
3030
cr "github.com/cortexlabs/cortex/pkg/lib/configreader"
31+
"github.com/cortexlabs/cortex/pkg/lib/console"
3132
"github.com/cortexlabs/cortex/pkg/lib/docker"
3233
"github.com/cortexlabs/cortex/pkg/lib/errors"
3334
"github.com/cortexlabs/cortex/pkg/lib/exit"
@@ -159,7 +160,7 @@ var _upCmd = &cobra.Command{
159160
exit.Error(ErrorClusterUp(out + helpStr))
160161
}
161162

162-
fmt.Printf("\nyour cli environment named \"%s\" has been configured to connect to this cluster; append --env=%s in cortex commands to reference it, or set it as your default via `cortex env default %s`\n", _flagClusterEnv, _flagClusterEnv, _flagClusterEnv)
163+
fmt.Printf(console.Bold("\nan environment named \"%s\" has been configured for this cluster; append `--env=%s` to cortex commands to reference it, or set it as your default with `cortex env default %s`\n"), _flagClusterEnv, _flagClusterEnv, _flagClusterEnv)
163164
},
164165
}
165166

cli/cmd/env.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ var _envListCmd = &cobra.Command{
128128
defaultEnv := getDefaultEnv(_generalCommandType)
129129

130130
for i, env := range cliConfig.Environments {
131-
fmt.Println(env.String(defaultEnv == env.Name))
131+
fmt.Print(env.String(defaultEnv == env.Name))
132132
if i+1 < len(cliConfig.Environments) {
133133
fmt.Println()
134134
}

cli/cmd/errors.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const (
4949
ErrEnvironmentNotFound = "cli.environment_not_found"
5050
ErrOperatorEndpointInLocalEnvironment = "cli.operator_endpoint_in_local_environment"
5151
ErrOperatorConfigFromLocalEnvironment = "cli.operater_config_from_local_environment"
52-
ErrFieldNotFoundInEnvironment = "cli.err_field_not_found_in_environment"
52+
ErrFieldNotFoundInEnvironment = "cli.field_not_found_in_environment"
5353
ErrInvalidOperatorEndpoint = "cli.invalid_operator_endpoint"
5454
ErrCortexYAMLNotFound = "cli.cortex_yaml_not_found"
5555
ErrConnectToDockerDaemon = "cli.connect_to_docker_daemon"

cli/cmd/lib_cluster_config.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,6 @@ func confirmInstallClusterConfig(clusterConfig *clusterconfig.Config, awsCreds A
434434
}
435435
fmt.Printf("cortex will also create an s3 bucket (%s) and a cloudwatch log group (%s)%s\n\n", clusterConfig.Bucket, clusterConfig.LogGroup, privateSubnetMsg)
436436

437-
fmt.Printf("your cli environment named \"%s\" will be configured to connect to this cluster\n\n", envName)
438-
439437
if clusterConfig.APILoadBalancerScheme == clusterconfig.InternalLoadBalancerScheme {
440438
fmt.Print("warning: you've configured the API load balancer to be internal; you must configure VPC Peering or an API Gateway VPC Link to connect to your APIs (see www.cortex.dev/guides/vpc-peering or www.cortex.dev/guides/api-gateway)\n\n")
441439
}

cli/cmd/lib_manager.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import (
3939
"github.com/docker/docker/api/types/mount"
4040
)
4141

42-
func runManager(containerConfig *container.Config) (string, *int, error) {
42+
func runManager(containerConfig *container.Config, addNewLineAfterPull bool) (string, *int, error) {
4343
containerConfig.Env = append(containerConfig.Env, "CORTEX_CLI_VERSION="+consts.CortexVersion)
4444

4545
// Add a slight delay before running the command to ensure logs don't start until after the container is attached
@@ -55,7 +55,7 @@ func runManager(containerConfig *container.Config) (string, *int, error) {
5555
return "", nil, err
5656
}
5757

58-
if pulledImage {
58+
if pulledImage && addNewLineAfterPull {
5959
fmt.Println()
6060
}
6161

@@ -180,7 +180,7 @@ func runManagerUpdateCommand(entrypoint string, clusterConfig *clusterconfig.Con
180180
},
181181
}
182182

183-
output, exitCode, err := runManager(containerConfig)
183+
output, exitCode, err := runManager(containerConfig, false)
184184
if err != nil {
185185
return "", nil, err
186186
}
@@ -207,7 +207,7 @@ func runManagerAccessCommand(entrypoint string, accessConfig clusterconfig.Acces
207207
},
208208
}
209209

210-
output, exitCode, err := runManager(containerConfig)
210+
output, exitCode, err := runManager(containerConfig, true)
211211
if err != nil {
212212
return "", nil, err
213213
}

cli/local/errors.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const (
2727
ErrNotAbsolutePath = "local.not_absolute_path"
2828
ErrAPINotDeployed = "local.api_not_deployed"
2929
ErrAPISpecNotFound = "local.api_specification_not_found"
30-
ErrCortexVersionMismatch = "local.err_cortex_version_mismatch"
30+
ErrCortexVersionMismatch = "local.cortex_version_mismatch"
3131
ErrAPIContainersNotFound = "local.api_containers_not_found"
3232
ErrFoundContainersWithoutAPISpec = "local.found_containers_without_api_spec"
3333
ErrInvalidTensorFlowZip = "local.invalid_tensorflow_zip"

cli/local/model_cache.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ func CacheModel(modelPath string, awsClient *aws.Client) (*spec.LocalModelCache,
9999
}
100100

101101
func downloadModel(modelPath string, modelDir string, awsClient *aws.Client) error {
102-
fmt.Printf("downloading model %s ", modelPath)
103-
defer fmt.Print("\n")
102+
fmt.Printf("downloading model %s ", modelPath)
103+
defer fmt.Print("\n")
104104
dotCron := cron.Run(print.Dot, nil, 2*time.Second)
105105
defer dotCron.Cancel()
106106

pkg/lib/docker/docker.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ func PullImage(image string, encodedAuthConfig string, pullVerbosity PullVerbosi
169169
jsonmessage.DisplayJSONMessagesStream(pullOutput, os.Stderr, termFd, isTerm, nil)
170170
fmt.Println()
171171
case PrintDots:
172-
fmt.Printf("downloading docker image %s ", image)
173-
defer fmt.Print("\n")
172+
fmt.Printf("downloading docker image %s ", image)
173+
defer fmt.Print("\n")
174174
dotCron := cron.Run(print.Dot, nil, 2*time.Second)
175175
defer dotCron.Cancel()
176176
// wait until the pull has completed

pkg/types/clusterconfig/clusterconfig.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,6 @@ func InstallPrompt(clusterConfig *Config, awsClient *aws.Client, disallowPrompt
741741
}
742742

743743
remainingPrompts := &cr.PromptValidation{
744-
SkipNonNilFields: true,
745744
SkipNonEmptyFields: true,
746745
PromptItemValidations: []*cr.PromptItemValidation{
747746
{

0 commit comments

Comments
 (0)