Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit 4391216

Browse files
committed
Migrate envs
1 parent 0c056bd commit 4391216

File tree

3 files changed

+28
-39
lines changed

3 files changed

+28
-39
lines changed

cmd/coder/envs.go

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,31 @@ package main
33
import (
44
"fmt"
55

6-
"github.com/spf13/pflag"
7-
8-
"go.coder.com/cli"
6+
"github.com/urfave/cli"
97
)
108

11-
type envsCmd struct {
12-
}
13-
14-
func (cmd envsCmd) Spec() cli.CommandSpec {
15-
return cli.CommandSpec{
16-
Name: "envs",
17-
Desc: "get a list of environments owned by the authenticated user",
18-
}
19-
}
20-
21-
func (cmd envsCmd) Run(fl *pflag.FlagSet) {
22-
entClient := requireAuth()
23-
24-
envs := getEnvs(entClient)
25-
26-
for _, env := range envs {
27-
fmt.Println(env.Name)
9+
func makeEnvsCommand() cli.Command {
10+
return cli.Command{
11+
Name: "envs",
12+
UsageText: "",
13+
Description: "interact with Coder environments",
14+
Subcommands: []cli.Command{
15+
{
16+
Name: "ls",
17+
Usage: "list all environments owned by the active user",
18+
UsageText: "",
19+
Description: "",
20+
ArgsUsage: "[...flags]>",
21+
Action: func(c *cli.Context) {
22+
entClient := requireAuth()
23+
envs := getEnvs(entClient)
24+
25+
for _, env := range envs {
26+
fmt.Println(env.Name)
27+
}
28+
},
29+
Flags: nil,
30+
},
31+
},
2832
}
2933
}

cmd/coder/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ func (r *rootCmd) Spec() cdrcli.CommandSpec {
3737

3838
func (r *rootCmd) Subcommands() []cdrcli.Command {
3939
return []cdrcli.Command{
40-
&envsCmd{},
4140
&syncCmd{},
4241
&urlsCmd{},
4342
}
@@ -67,6 +66,7 @@ func main() {
6766
makeUsersCmd(),
6867
makeConfigSSHCmd(),
6968
makeSecretsCmd(),
69+
makeEnvsCommand(),
7070
}
7171
err = app.Run(os.Args)
7272
if err != nil {

cmd/coder/shell.go

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,9 @@ func makeShellCmd() cli.Command {
2626
Description: "execute a remote command on the environment\\nIf no command is specified, the default shell is opened.",
2727
SkipFlagParsing: true,
2828
SkipArgReorder: true,
29-
30-
ShortName: "",
31-
Aliases: nil,
32-
UsageText: "",
33-
ArgsUsage: "",
34-
Category: "",
35-
BashComplete: nil,
36-
Before: nil,
37-
After: nil,
38-
Action: shell,
39-
OnUsageError: nil,
40-
Subcommands: nil,
41-
Flags: nil,
42-
HideHelp: false,
43-
Hidden: false,
44-
UseShortOptionHandling: false,
45-
HelpName: "",
46-
CustomHelpTemplate: "",
29+
UsageText: "",
30+
ArgsUsage: "",
31+
Action: shell,
4732
}
4833
}
4934

0 commit comments

Comments
 (0)