From 37989d29efe097e942513ea941e289704df8c677 Mon Sep 17 00:00:00 2001 From: ketang <33678+ketang@users.noreply.github.com> Date: Mon, 4 Jul 2022 11:57:22 -0500 Subject: [PATCH] add date/time stamps to output at end of some workspace and template subcommands (#2814) --- cli/cliui/cliui.go | 2 ++ cli/create.go | 2 +- cli/delete.go | 2 +- cli/start.go | 2 +- cli/stop.go | 2 +- cli/templatecreate.go | 2 +- cli/templatedelete.go | 3 ++- cli/templateedit.go | 2 +- cli/templateupdate.go | 2 +- 9 files changed, 11 insertions(+), 8 deletions(-) diff --git a/cli/cliui/cliui.go b/cli/cliui/cliui.go index 80aa7fa14e0d8..4e2666784a2b0 100644 --- a/cli/cliui/cliui.go +++ b/cli/cliui/cliui.go @@ -26,6 +26,7 @@ var Styles = struct { Checkmark, Code, Crossmark, + DateTimeStamp, Error, Field, Keyword, @@ -42,6 +43,7 @@ var Styles = struct { Checkmark: defaultStyles.Checkmark, Code: defaultStyles.Code, Crossmark: defaultStyles.Error.Copy().SetString("✘"), + DateTimeStamp: defaultStyles.LabelDim, Error: defaultStyles.Error, Field: defaultStyles.Code.Copy().Foreground(lipgloss.AdaptiveColor{Light: "#000000", Dark: "#FFFFFF"}), Keyword: defaultStyles.Keyword, diff --git a/cli/create.go b/cli/create.go index f76e497982978..f1fe396fbe088 100644 --- a/cli/create.go +++ b/cli/create.go @@ -155,7 +155,7 @@ func create() *cobra.Command { return err } - _, _ = fmt.Fprintf(cmd.OutOrStdout(), "\nThe %s workspace has been created!\n", cliui.Styles.Keyword.Render(workspace.Name)) + _, _ = fmt.Fprintf(cmd.OutOrStdout(), "\nThe %s workspace has been created at %s!\n", cliui.Styles.Keyword.Render(workspace.Name), cliui.Styles.DateTimeStamp.Render(time.Now().Format(time.Stamp))) return nil }, } diff --git a/cli/delete.go b/cli/delete.go index c8b2345c9c2b1..ea4ef0ac2a4d7 100644 --- a/cli/delete.go +++ b/cli/delete.go @@ -48,7 +48,7 @@ func deleteWorkspace() *cobra.Command { return err } - _, _ = fmt.Fprintf(cmd.OutOrStdout(), "\nThe %s workspace has been deleted!\n", cliui.Styles.Keyword.Render(workspace.Name)) + _, _ = fmt.Fprintf(cmd.OutOrStdout(), "\nThe %s workspace has been deleted at %s!\n", cliui.Styles.Keyword.Render(workspace.Name), cliui.Styles.DateTimeStamp.Render(time.Now().Format(time.Stamp))) return nil }, } diff --git a/cli/start.go b/cli/start.go index 7c48de20cb892..bb062903c61c9 100644 --- a/cli/start.go +++ b/cli/start.go @@ -46,7 +46,7 @@ func start() *cobra.Command { return err } - _, _ = fmt.Fprintf(cmd.OutOrStdout(), "\nThe %s workspace has been started!\n", cliui.Styles.Keyword.Render(workspace.Name)) + _, _ = fmt.Fprintf(cmd.OutOrStdout(), "\nThe %s workspace has been started at %s!\n", cliui.Styles.Keyword.Render(workspace.Name), cliui.Styles.DateTimeStamp.Render(time.Now().Format(time.Stamp))) return nil }, } diff --git a/cli/stop.go b/cli/stop.go index 33c0d10cbeca2..381e7634b9a90 100644 --- a/cli/stop.go +++ b/cli/stop.go @@ -46,7 +46,7 @@ func stop() *cobra.Command { return err } - _, _ = fmt.Fprintf(cmd.OutOrStdout(), "\nThe %s workspace has been stopped!\n", cliui.Styles.Keyword.Render(workspace.Name)) + _, _ = fmt.Fprintf(cmd.OutOrStdout(), "\nThe %s workspace has been stopped at %s!\n", cliui.Styles.Keyword.Render(workspace.Name), cliui.Styles.DateTimeStamp.Render(time.Now().Format(time.Stamp))) return nil }, } diff --git a/cli/templatecreate.go b/cli/templatecreate.go index e7aad2d51305b..226b12daa9833 100644 --- a/cli/templatecreate.go +++ b/cli/templatecreate.go @@ -114,7 +114,7 @@ func templateCreate() *cobra.Command { } _, _ = fmt.Fprintln(cmd.OutOrStdout(), "\n"+cliui.Styles.Wrap.Render( - "The "+cliui.Styles.Keyword.Render(templateName)+" template has been created! "+ + "The "+cliui.Styles.Keyword.Render(templateName)+" template has been created at "+cliui.Styles.DateTimeStamp.Render(time.Now().Format(time.Stamp))+"! "+ "Developers can provision a workspace with this template using:")+"\n") _, _ = fmt.Fprintln(cmd.OutOrStdout(), " "+cliui.Styles.Code.Render(fmt.Sprintf("coder create --template=%q [workspace name]", templateName))) diff --git a/cli/templatedelete.go b/cli/templatedelete.go index e698335c672a6..0ca9929daa0c4 100644 --- a/cli/templatedelete.go +++ b/cli/templatedelete.go @@ -2,6 +2,7 @@ package cli import ( "fmt" + "time" "github.com/spf13/cobra" "golang.org/x/xerrors" @@ -76,7 +77,7 @@ func templateDelete() *cobra.Command { return xerrors.Errorf("delete template %q: %w", template.Name, err) } - _, _ = fmt.Fprintln(cmd.OutOrStdout(), "Deleted template "+cliui.Styles.Code.Render(template.Name)+"!") + _, _ = fmt.Fprintln(cmd.OutOrStdout(), "Deleted template "+cliui.Styles.Code.Render(template.Name)+" at "+cliui.Styles.DateTimeStamp.Render(time.Now().Format(time.Stamp))+"!") } return nil diff --git a/cli/templateedit.go b/cli/templateedit.go index 7ec0305593280..6f614b55a3a4b 100644 --- a/cli/templateedit.go +++ b/cli/templateedit.go @@ -47,7 +47,7 @@ func templateEdit() *cobra.Command { if err != nil { return xerrors.Errorf("update template metadata: %w", err) } - _, _ = fmt.Printf("Updated template metadata!\n") + _, _ = fmt.Printf("Updated template metadata at %s!\n", cliui.Styles.DateTimeStamp.Render(time.Now().Format(time.Stamp))) return nil }, } diff --git a/cli/templateupdate.go b/cli/templateupdate.go index 15b2c512fe35b..d283788939d47 100644 --- a/cli/templateupdate.go +++ b/cli/templateupdate.go @@ -98,7 +98,7 @@ func templateUpdate() *cobra.Command { return err } - _, _ = fmt.Printf("Updated version!\n") + _, _ = fmt.Printf("Updated version at %s!\n", cliui.Styles.DateTimeStamp.Render(time.Now().Format(time.Stamp))) return nil }, }