Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2609be7

Browse files
authored
feat: add timestamps to output at end of some workspace and template subcommands (coder#2831)
1 parent 584448e commit 2609be7

9 files changed

+11
-8
lines changed

cli/cliui/cliui.go

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ var Styles = struct {
2626
Checkmark,
2727
Code,
2828
Crossmark,
29+
DateTimeStamp,
2930
Error,
3031
Field,
3132
Keyword,
@@ -42,6 +43,7 @@ var Styles = struct {
4243
Checkmark: defaultStyles.Checkmark,
4344
Code: defaultStyles.Code,
4445
Crossmark: defaultStyles.Error.Copy().SetString("✘"),
46+
DateTimeStamp: defaultStyles.LabelDim,
4547
Error: defaultStyles.Error,
4648
Field: defaultStyles.Code.Copy().Foreground(lipgloss.AdaptiveColor{Light: "#000000", Dark: "#FFFFFF"}),
4749
Keyword: defaultStyles.Keyword,

cli/create.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ func create() *cobra.Command {
155155
return err
156156
}
157157

158-
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "\nThe %s workspace has been created!\n", cliui.Styles.Keyword.Render(workspace.Name))
158+
_, _ = 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)))
159159
return nil
160160
},
161161
}

cli/delete.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func deleteWorkspace() *cobra.Command {
4848
return err
4949
}
5050

51-
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "\nThe %s workspace has been deleted!\n", cliui.Styles.Keyword.Render(workspace.Name))
51+
_, _ = 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)))
5252
return nil
5353
},
5454
}

cli/start.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func start() *cobra.Command {
4646
return err
4747
}
4848

49-
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "\nThe %s workspace has been started!\n", cliui.Styles.Keyword.Render(workspace.Name))
49+
_, _ = 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)))
5050
return nil
5151
},
5252
}

cli/stop.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func stop() *cobra.Command {
4646
return err
4747
}
4848

49-
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "\nThe %s workspace has been stopped!\n", cliui.Styles.Keyword.Render(workspace.Name))
49+
_, _ = 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)))
5050
return nil
5151
},
5252
}

cli/templatecreate.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func templateCreate() *cobra.Command {
114114
}
115115

116116
_, _ = fmt.Fprintln(cmd.OutOrStdout(), "\n"+cliui.Styles.Wrap.Render(
117-
"The "+cliui.Styles.Keyword.Render(templateName)+" template has been created! "+
117+
"The "+cliui.Styles.Keyword.Render(templateName)+" template has been created at "+cliui.Styles.DateTimeStamp.Render(time.Now().Format(time.Stamp))+"! "+
118118
"Developers can provision a workspace with this template using:")+"\n")
119119

120120
_, _ = fmt.Fprintln(cmd.OutOrStdout(), " "+cliui.Styles.Code.Render(fmt.Sprintf("coder create --template=%q [workspace name]", templateName)))

cli/templatedelete.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package cli
22

33
import (
44
"fmt"
5+
"time"
56

67
"github.com/spf13/cobra"
78
"golang.org/x/xerrors"
@@ -76,7 +77,7 @@ func templateDelete() *cobra.Command {
7677
return xerrors.Errorf("delete template %q: %w", template.Name, err)
7778
}
7879

79-
_, _ = fmt.Fprintln(cmd.OutOrStdout(), "Deleted template "+cliui.Styles.Code.Render(template.Name)+"!")
80+
_, _ = fmt.Fprintln(cmd.OutOrStdout(), "Deleted template "+cliui.Styles.Code.Render(template.Name)+" at "+cliui.Styles.DateTimeStamp.Render(time.Now().Format(time.Stamp))+"!")
8081
}
8182

8283
return nil

cli/templateedit.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func templateEdit() *cobra.Command {
4747
if err != nil {
4848
return xerrors.Errorf("update template metadata: %w", err)
4949
}
50-
_, _ = fmt.Printf("Updated template metadata!\n")
50+
_, _ = fmt.Printf("Updated template metadata at %s!\n", cliui.Styles.DateTimeStamp.Render(time.Now().Format(time.Stamp)))
5151
return nil
5252
},
5353
}

cli/templateupdate.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func templateUpdate() *cobra.Command {
9898
return err
9999
}
100100

101-
_, _ = fmt.Printf("Updated version!\n")
101+
_, _ = fmt.Printf("Updated version at %s!\n", cliui.Styles.DateTimeStamp.Render(time.Now().Format(time.Stamp)))
102102
return nil
103103
},
104104
}

0 commit comments

Comments
 (0)