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

Environment subcommands #89

Closed
wants to merge 14 commits into from
Prev Previous commit
Next Next commit
Migrate envs
  • Loading branch information
cmoog committed Jul 31, 2020
commit b2c08eb8faf848257b0abfd13369ba9f61751d12
44 changes: 24 additions & 20 deletions cmd/coder/envs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,31 @@ package main
import (
"fmt"

"github.com/spf13/pflag"

"go.coder.com/cli"
"github.com/urfave/cli"
)

type envsCmd struct {
}

func (cmd envsCmd) Spec() cli.CommandSpec {
return cli.CommandSpec{
Name: "envs",
Desc: "get a list of environments owned by the authenticated user",
}
}

func (cmd envsCmd) Run(fl *pflag.FlagSet) {
entClient := requireAuth()

envs := getEnvs(entClient)

for _, env := range envs {
fmt.Println(env.Name)
func makeEnvsCommand() cli.Command {
return cli.Command{
Name: "envs",
UsageText: "",
Description: "interact with Coder environments",
Subcommands: []cli.Command{
{
Name: "ls",
Usage: "list all environments owned by the active user",
UsageText: "",
Description: "",
ArgsUsage: "[...flags]>",
Action: func(c *cli.Context) {
entClient := requireAuth()
envs := getEnvs(entClient)

for _, env := range envs {
fmt.Println(env.Name)
}
},
Flags: nil,
},
},
}
}
2 changes: 1 addition & 1 deletion cmd/coder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ func (r *rootCmd) Spec() cdrcli.CommandSpec {

func (r *rootCmd) Subcommands() []cdrcli.Command {
return []cdrcli.Command{
&envsCmd{},
&syncCmd{},
&urlsCmd{},
}
Expand Down Expand Up @@ -67,6 +66,7 @@ func main() {
makeUsersCmd(),
makeConfigSSHCmd(),
makeSecretsCmd(),
makeEnvsCommand(),
}
err = app.Run(os.Args)
if err != nil {
Expand Down
21 changes: 3 additions & 18 deletions cmd/coder/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,9 @@ func makeShellCmd() cli.Command {
Description: "execute a remote command on the environment\\nIf no command is specified, the default shell is opened.",
SkipFlagParsing: true,
SkipArgReorder: true,

ShortName: "",
Aliases: nil,
UsageText: "",
ArgsUsage: "",
Category: "",
BashComplete: nil,
Before: nil,
After: nil,
Action: shell,
OnUsageError: nil,
Subcommands: nil,
Flags: nil,
HideHelp: false,
Hidden: false,
UseShortOptionHandling: false,
HelpName: "",
CustomHelpTemplate: "",
UsageText: "",
ArgsUsage: "",
Action: shell,
}
}

Expand Down