Properly pipe BD_ACTOR through to Comment.Author field in bd comments add. Add flag to bd comments add to accept author. Precedence is now glag, BD_ACTOR, USER
This commit is contained in:
committed by
Steve Yegge
parent
af0582ae5d
commit
9dcfa88711
@@ -127,17 +127,20 @@ Examples:
|
|||||||
commentText = args[1]
|
commentText = args[1]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get author from environment or system
|
// Get author from author flag, BD_ACTOR var, or system USER var
|
||||||
author := os.Getenv("BD_AUTHOR")
|
author, _ := cmd.Flags().GetString("author")
|
||||||
if author == "" {
|
if author == "" {
|
||||||
author = os.Getenv("USER")
|
author := os.Getenv("BD_ACTOR")
|
||||||
}
|
if author == "" {
|
||||||
if author == "" {
|
author = os.Getenv("USER")
|
||||||
if u, err := user.Current(); err == nil {
|
}
|
||||||
author = u.Username
|
if author == "" {
|
||||||
} else {
|
if u, err := user.Current(); err == nil {
|
||||||
author = "unknown"
|
author = u.Username
|
||||||
}
|
} else {
|
||||||
|
author = "unknown"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var comment *types.Comment
|
var comment *types.Comment
|
||||||
@@ -198,6 +201,7 @@ Examples:
|
|||||||
func init() {
|
func init() {
|
||||||
commentsCmd.AddCommand(commentsAddCmd)
|
commentsCmd.AddCommand(commentsAddCmd)
|
||||||
commentsAddCmd.Flags().StringP("file", "f", "", "Read comment text from file")
|
commentsAddCmd.Flags().StringP("file", "f", "", "Read comment text from file")
|
||||||
|
commentsAddCmd.Flags().StringP("author", "a", "", "Add author to comment")
|
||||||
rootCmd.AddCommand(commentsCmd)
|
rootCmd.AddCommand(commentsCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user