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
More improvements
  • Loading branch information
cmoog committed Jul 31, 2020
commit 748409ebafddd775eb9cbf984da3887f11c98f98
6 changes: 6 additions & 0 deletions cmd/coder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ func main() {
app.Name = "coder"
app.Usage = "coder provides a CLI for working with an existing Coder Enterprise installation"
app.Version = fmt.Sprintf("%s %s %s/%s", version, runtime.Version(), runtime.GOOS, runtime.GOARCH)
app.Author = "Coder Technologies Inc."
app.CommandNotFound = func(c *cli.Context, s string) {
flog.Fatal("command %q not found", s)
}
app.Email = "support@coder.com"

app.Commands = []cli.Command{
makeLoginCmd(),
makeLogoutCmd(),
Expand Down
27 changes: 18 additions & 9 deletions cmd/coder/secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ func makeSecretsCmd() cli.Command {
makeCreateSecret(),
{
Name: "rm",
Usage: "Remove a secret by name",
ArgsUsage: "[secret_name]",
Usage: "Remove one or more secrets by name",
ArgsUsage: "[...secret_name]",
Action: removeSecret,
},
{
Expand Down Expand Up @@ -175,14 +175,23 @@ func viewSecret(c *cli.Context) {
func removeSecret(c *cli.Context) {
var (
client = requireAuth()
name = c.Args().First()
names = append([]string{c.Args().First()}, c.Args().Tail()...)
)
if name == "" {
flog.Fatal("[name] is a required argument")
if len(names) < 1 || names[0] == "" {
flog.Fatal("[...secret_name] is a required argument")
}

err := client.DeleteSecretByName(name)
requireSuccess(err, "failed to delete secret: %v", err)

flog.Info("Successfully deleted secret %q", name)
errorSeen := false
for _, n := range names {
err := client.DeleteSecretByName(n)
if err != nil {
flog.Error("failed to delete secret: %v", err)
errorSeen = true
} else {
flog.Info("Successfully deleted secret %q", n)
}
}
if errorSeen {
os.Exit(1)
}
}
13 changes: 5 additions & 8 deletions cmd/coder/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,17 @@ import (
func makeUsersCmd() cli.Command {
var output string
return cli.Command{
Name: "users",
Usage: "Interact with Coder user accounts",
ArgsUsage: "[subcommand] <flags>",
Name: "users",
Usage: "Interact with Coder user accounts",
Subcommands: []cli.Command{
{
Name: "ls",
Usage: "list all user accounts",
Description: "",
Action: listUsers(&output),
Name: "ls",
Usage: "list all user accounts",
Action: listUsers(&output),
Flags: []cli.Flag{
cli.StringFlag{
Name: "output",
Usage: "(json | human)",
Required: false,
Value: "human",
Destination: &output,
},
Expand Down