Skip to content

Commit c5f6294

Browse files
committed
Switch to ms output for getting plugins
This is better granularity than showing 0s which could have been 100ms for instance. Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
1 parent 30fa81c commit c5f6294

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

commands/plugin_get.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,21 @@ func runPluginGetCmd(cmd *cobra.Command, args []string) error {
157157
}
158158

159159
if cmd.Flags().Changed("path") {
160-
fmt.Printf("Wrote: %s (%s/%s) in (%s)\n", path.Join(pluginPath, pluginName), clientOS, clientArch, time.Since(st).Round(time.Millisecond))
160+
fmt.Printf("Wrote: %s (%s/%s) in (%s)\n", path.Join(pluginPath, pluginName), clientOS, clientArch, formatDownloadDuration(time.Since(st)))
161161
} else {
162-
fmt.Printf("Downloaded in (%s)\n\nUsage:\n faas-cli %s\n", time.Since(st).Round(time.Millisecond), pluginName)
162+
fmt.Printf("Downloaded in (%s)\n\nUsage:\n faas-cli %s\n", formatDownloadDuration(time.Since(st)), pluginName)
163163
}
164164
return nil
165165
}
166166

167+
func formatDownloadDuration(downloadTime time.Duration) string {
168+
if downloadTime < time.Millisecond {
169+
return "<1ms"
170+
}
171+
172+
return downloadTime.Round(time.Millisecond).String()
173+
}
174+
167175
func getClientArch() (arch string, os string) {
168176
if runtime.GOOS == "windows" {
169177
return runtime.GOARCH, runtime.GOOS

0 commit comments

Comments
 (0)