Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli/silence_add: don't ingore errors when getting current user #1031

Merged
merged 1 commit into from
Oct 9, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions cli/silence_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,16 @@ var addCmd = &cobra.Command{
}

func init() {
user, _ := user.Current()
addCmd.Flags().StringP("author", "a", user.Username, "Username for CreatedBy field")
var username string

user, err := user.Current()
if err != nil {
fmt.Printf("failed to get the current user, specify one with --author: %v\n", err)
} else {
username = user.Username
}

addCmd.Flags().StringP("author", "a", username, "Username for CreatedBy field")
addCmd.Flags().StringP("expires", "e", "1h", "Duration of silence (100h)")
addCmd.Flags().String("expire-on", "", "Expire at a certain time (Overwrites expires) RFC3339 format 2006-01-02T15:04:05Z07:00")
addCmd.Flags().StringP("comment", "c", "", "A comment to help describe the silence")
Expand Down