diff --git a/docs/coder_envs.md b/docs/coder_envs.md index 176ab6b8..2239747e 100644 --- a/docs/coder_envs.md +++ b/docs/coder_envs.md @@ -23,5 +23,7 @@ Perform operations on the Coder environments owned by the active user. * [coder](coder.md) - coder provides a CLI for working with an existing Coder Enterprise installation * [coder envs ls](coder_envs_ls.md) - list all environments owned by the active user +* [coder envs rebuild](coder_envs_rebuild.md) - rebuild a Coder environment * [coder envs stop](coder_envs_stop.md) - stop Coder environments by name +* [coder envs watch-build](coder_envs_watch-build.md) - trail the build log of a Coder environment diff --git a/docs/coder_envs_rebuild.md b/docs/coder_envs_rebuild.md new file mode 100644 index 00000000..bcfdcd3c --- /dev/null +++ b/docs/coder_envs_rebuild.md @@ -0,0 +1,34 @@ +## coder envs rebuild + +rebuild a Coder environment + +``` +coder envs rebuild [environment_name] [flags] +``` + +### Examples + +``` +coder envs rebuild front-end-env --follow +coder envs rebuild backend-env --force +``` + +### Options + +``` + --follow follow build log after initiating rebuild + --force force rebuild without showing a confirmation prompt + -h, --help help for rebuild +``` + +### Options inherited from parent commands + +``` + --user string Specify the user whose resources to target (default "me") + -v, --verbose show verbose output +``` + +### SEE ALSO + +* [coder envs](coder_envs.md) - Interact with Coder environments + diff --git a/docs/coder_envs_watch-build.md b/docs/coder_envs_watch-build.md new file mode 100644 index 00000000..7065a6b6 --- /dev/null +++ b/docs/coder_envs_watch-build.md @@ -0,0 +1,31 @@ +## coder envs watch-build + +trail the build log of a Coder environment + +``` +coder envs watch-build [environment_name] [flags] +``` + +### Examples + +``` +coder envs watch-build front-end-env +``` + +### Options + +``` + -h, --help help for watch-build +``` + +### Options inherited from parent commands + +``` + --user string Specify the user whose resources to target (default "me") + -v, --verbose show verbose output +``` + +### SEE ALSO + +* [coder envs](coder_envs.md) - Interact with Coder environments + diff --git a/internal/cmd/envs.go b/internal/cmd/envs.go index fcdd5b56..5a059d76 100644 --- a/internal/cmd/envs.go +++ b/internal/cmd/envs.go @@ -30,8 +30,8 @@ func envsCommand() *cobra.Command { lsEnvsCommand(&user), stopEnvsCommand(&user), rmEnvsCommand(&user), - watchBuildLogCommand(), - rebuildEnvCommand(), + watchBuildLogCommand(&user), + rebuildEnvCommand(&user), createEnvCommand(&user), editEnvCommand(&user), ) diff --git a/internal/cmd/rebuild.go b/internal/cmd/rebuild.go index 8e6de326..958af18f 100644 --- a/internal/cmd/rebuild.go +++ b/internal/cmd/rebuild.go @@ -17,7 +17,7 @@ import ( "golang.org/x/xerrors" ) -func rebuildEnvCommand() *cobra.Command { +func rebuildEnvCommand(user *string) *cobra.Command { var follow bool var force bool cmd := &cobra.Command{ @@ -26,14 +26,13 @@ func rebuildEnvCommand() *cobra.Command { Args: cobra.ExactArgs(1), Example: `coder envs rebuild front-end-env --follow coder envs rebuild backend-env --force`, - Hidden: true, // TODO(@cmoog) un-hide RunE: func(cmd *cobra.Command, args []string) error { ctx := cmd.Context() client, err := newClient() if err != nil { return err } - env, err := findEnv(ctx, client, args[0], coder.Me) + env, err := findEnv(ctx, client, args[0], *user) if err != nil { return err } @@ -44,7 +43,10 @@ coder envs rebuild backend-env --force`, IsConfirm: true, }).Run() if err != nil { - return err + return clog.Fatal( + "failed to confirm prompt", clog.BlankLine, + clog.Tipf(`use "--force" to rebuild without a confirmation prompt`), + ) } } @@ -65,7 +67,7 @@ coder envs rebuild backend-env --force`, }, } - cmd.Flags().BoolVar(&follow, "follow", false, "follow buildlog after initiating rebuild") + cmd.Flags().BoolVar(&follow, "follow", false, "follow build log after initiating rebuild") cmd.Flags().BoolVar(&force, "force", false, "force rebuild without showing a confirmation prompt") return cmd } @@ -134,20 +136,19 @@ func trailBuildLogs(ctx context.Context, client *coder.Client, envID string) err return nil } -func watchBuildLogCommand() *cobra.Command { +func watchBuildLogCommand(user *string) *cobra.Command { cmd := &cobra.Command{ Use: "watch-build [environment_name]", - Example: "coder watch-build front-end-env", + Example: "coder envs watch-build front-end-env", Short: "trail the build log of a Coder environment", Args: cobra.ExactArgs(1), - Hidden: true, // TODO(@cmoog) un-hide RunE: func(cmd *cobra.Command, args []string) error { ctx := cmd.Context() client, err := newClient() if err != nil { return err } - env, err := findEnv(ctx, client, args[0], coder.Me) + env, err := findEnv(ctx, client, args[0], *user) if err != nil { return err }