- Notifications
You must be signed in to change notification settings - Fork928
feat(cli): add local and UTC time options toping
cmd#16648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes from1 commit
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
Signed-off-by: Danny Kopping <danny@coder.com>
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -86,6 +86,8 @@ func (r *RootCmd) ping() *serpent.Command { | ||
pingNum int64 | ||
pingTimeout time.Duration | ||
pingWait time.Duration | ||
pingTime bool | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. nit: could we call this | ||
pingTimeUTC bool | ||
appearanceConfig codersdk.AppearanceConfig | ||
) | ||
@@ -217,6 +219,10 @@ func (r *RootCmd) ping() *serpent.Command { | ||
ctx, cancel := context.WithTimeout(ctx, pingTimeout) | ||
dur, p2p, pong, err = conn.Ping(ctx) | ||
pongTime := time.Now() | ||
if pingTimeUTC { | ||
pongTime = pongTime.UTC() | ||
} | ||
cancel() | ||
results.addResult(pong) | ||
if err != nil { | ||
@@ -268,7 +274,13 @@ func (r *RootCmd) ping() *serpent.Command { | ||
) | ||
} | ||
var displayTime string | ||
if pingTime || pingTimeUTC { | ||
displayTime = pretty.Sprintf(cliui.DefaultStyles.DateTimeStamp, "[%s] ", pongTime.Format(time.RFC3339)) | ||
} | ||
_, _ = fmt.Fprintf(inv.Stdout, "%spong from %s %s in %s\n", | ||
displayTime, | ||
pretty.Sprint(cliui.DefaultStyles.Keyword, workspaceName), | ||
via, | ||
pretty.Sprint(cliui.DefaultStyles.DateTimeStamp, dur.String()), | ||
@@ -321,6 +333,16 @@ func (r *RootCmd) ping() *serpent.Command { | ||
Description: "Specifies the number of pings to perform. By default, pings will continue until interrupted.", | ||
Value: serpent.Int64Of(&pingNum), | ||
}, | ||
{ | ||
Flag: "time", | ||
Description: "Show the response time of each pong in local time.", | ||
Value: serpent.BoolOf(&pingTime), | ||
}, | ||
{ | ||
Flag: "utc", | ||
Description: "Show the response time of each pong in UTC (implies --time).", | ||
Value: serpent.BoolOf(&pingTimeUTC), | ||
}, | ||
} | ||
return cmd | ||
} | ||
Uh oh!
There was an error while loading.Please reload this page.