Skip to content

Commit

Permalink
feat(CLI): Unify CLI style about env and image (#550)
Browse files Browse the repository at this point in the history
* unify cli style

Signed-off-by: Jinjing.Zhou <allenzhou@tensorchord.ai>

* fix style

Signed-off-by: Jinjing.Zhou <allenzhou@tensorchord.ai>

* fix test

Signed-off-by: Jinjing.Zhou <allenzhou@tensorchord.ai>

* fix test

Signed-off-by: Jinjing.Zhou <allenzhou@tensorchord.ai>

* address comment

Signed-off-by: Jinjing.Zhou <allenzhou@tensorchord.ai>
  • Loading branch information
VoVAllen committed Jul 5, 2022
1 parent 50bf248 commit f71cd7f
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 50 deletions.
3 changes: 2 additions & 1 deletion pkg/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ func New() EnvdApp {
CommandBuild,
CommandContext,
CommandDestroy,
CommandGet,
CommandEnvironment,
CommandImage,
CommandInit,
CommandPause,
CommandPrune,
Expand Down
15 changes: 11 additions & 4 deletions pkg/app/get_env.go → pkg/app/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,22 @@ import (
"github.com/tensorchord/envd/pkg/types"
)

var CommandGetEnvironment = &cli.Command{
var CommandEnvironment = &cli.Command{
Name: "envs",
Aliases: []string{"env", "e"},
Usage: "List envd environments",
Usage: "Manage envd environments",

Subcommands: []*cli.Command{
CommandGetEnvironmentDependency,
CommandDescribeEnvironment,
CommandListEnv,
},
Action: getEnvironment,
}

var CommandListEnv = &cli.Command{
Name: "list",
Aliases: []string{"ls", "l"},
Usage: "List envd environments",
Action: getEnvironment,
}

func getEnvironment(clicontext *cli.Context) error {
Expand Down
8 changes: 4 additions & 4 deletions pkg/app/get_env_dep.go → pkg/app/env_describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ import (
"github.com/tensorchord/envd/pkg/types"
)

var CommandGetEnvironmentDependency = &cli.Command{
Name: "deps",
Aliases: []string{"dep", "d"},
Usage: "List all dependencies",
var CommandDescribeEnvironment = &cli.Command{
Name: "describe",
Aliases: []string{"d"},
Usage: "Show details about environments, including dependencies",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "env",
Expand Down
30 changes: 0 additions & 30 deletions pkg/app/get.go

This file was deleted.

2 changes: 1 addition & 1 deletion pkg/app/get_env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (

var _ = Describe("get env command", func() {
args := []string{
"envd.test", "--debug", "get", "envs",
"envd.test", "--debug", "envs", "list",
}
BeforeEach(func() {
Expect(home.Initialize()).NotTo(HaveOccurred())
Expand Down
14 changes: 10 additions & 4 deletions pkg/app/get_image.go → pkg/app/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,22 @@ import (
"github.com/tensorchord/envd/pkg/types"
)

var CommandGetImage = &cli.Command{
var CommandImage = &cli.Command{
Name: "images",
Aliases: []string{"image", "i"},
Usage: "List envd images",
Usage: "Manage envd images",

Subcommands: []*cli.Command{
CommandGetImageDependency,
CommandDescribeImage,
CommandListImage,
},
}

Action: getImage,
var CommandListImage = &cli.Command{
Name: "list",
Aliases: []string{"ls", "l"},
Usage: "List envd images",
Action: getImage,
}

func getImage(clicontext *cli.Context) error {
Expand Down
8 changes: 4 additions & 4 deletions pkg/app/get_image_dep.go → pkg/app/image_describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ import (
"github.com/tensorchord/envd/pkg/envd"
)

var CommandGetImageDependency = &cli.Command{
Name: "deps",
Aliases: []string{"dep", "d"},
Usage: "List all dependencies in the image",
var CommandDescribeImage = &cli.Command{
Name: "describe",
Aliases: []string{"d"},
Usage: "Show details about image, including dependencies",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "image",
Expand Down
2 changes: 1 addition & 1 deletion pkg/app/up_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var _ = Describe("up command", func() {
Expect(err).NotTo(HaveOccurred())

depsArgs := append(baseArgs, []string{
"get", "envs", "deps", "--env", env,
"envs", "describe", "--env", env,
}...)

err = app.Run(depsArgs)
Expand Down
2 changes: 1 addition & 1 deletion pkg/shell/zsh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/tensorchord/envd/pkg/util/fileutil"
)

var _ = Describe("zsh manager", func() {
var _ = Describe("zsh manager", Serial, func() {
zshManager := NewManager()
BeforeEach(func() {
Expect(home.Initialize()).NotTo(HaveOccurred())
Expand Down

0 comments on commit f71cd7f

Please sign in to comment.