feat(create): add -m as alias for --description flag
Add --message/-m as a hidden alias for --description on bd create, matching the git commit -m convention for muscle memory. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
committed by
gastown/crew/george
parent
0b6df198a5
commit
e0dc3a37c3
@@ -14,6 +14,8 @@ func registerCommonIssueFlags(cmd *cobra.Command) {
|
|||||||
cmd.Flags().StringP("description", "d", "", "Issue description")
|
cmd.Flags().StringP("description", "d", "", "Issue description")
|
||||||
cmd.Flags().String("body", "", "Alias for --description (GitHub CLI convention)")
|
cmd.Flags().String("body", "", "Alias for --description (GitHub CLI convention)")
|
||||||
_ = cmd.Flags().MarkHidden("body") // Hidden alias for agent/CLI ergonomics
|
_ = cmd.Flags().MarkHidden("body") // Hidden alias for agent/CLI ergonomics
|
||||||
|
cmd.Flags().StringP("message", "m", "", "Alias for --description (git commit convention)")
|
||||||
|
_ = cmd.Flags().MarkHidden("message") // Hidden alias for muscle memory from git commit -m
|
||||||
cmd.Flags().String("body-file", "", "Read description from file (use - for stdin)")
|
cmd.Flags().String("body-file", "", "Read description from file (use - for stdin)")
|
||||||
cmd.Flags().String("description-file", "", "Alias for --body-file")
|
cmd.Flags().String("description-file", "", "Alias for --body-file")
|
||||||
_ = cmd.Flags().MarkHidden("description-file") // Hidden alias
|
_ = cmd.Flags().MarkHidden("description-file") // Hidden alias
|
||||||
@@ -33,6 +35,7 @@ func getDescriptionFlag(cmd *cobra.Command) (string, bool) {
|
|||||||
descFileChanged := cmd.Flags().Changed("description-file")
|
descFileChanged := cmd.Flags().Changed("description-file")
|
||||||
descChanged := cmd.Flags().Changed("description")
|
descChanged := cmd.Flags().Changed("description")
|
||||||
bodyChanged := cmd.Flags().Changed("body")
|
bodyChanged := cmd.Flags().Changed("body")
|
||||||
|
messageChanged := cmd.Flags().Changed("message")
|
||||||
|
|
||||||
// Check for conflicting file flags
|
// Check for conflicting file flags
|
||||||
if bodyFileChanged && descFileChanged {
|
if bodyFileChanged && descFileChanged {
|
||||||
@@ -54,8 +57,8 @@ func getDescriptionFlag(cmd *cobra.Command) (string, bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Error if both file and string flags are specified
|
// Error if both file and string flags are specified
|
||||||
if descChanged || bodyChanged {
|
if descChanged || bodyChanged || messageChanged {
|
||||||
fmt.Fprintf(os.Stderr, "Error: cannot specify both --body-file and --description/--body\n")
|
fmt.Fprintf(os.Stderr, "Error: cannot specify both --body-file and --description/--body/--message\n")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,19 +70,38 @@ func getDescriptionFlag(cmd *cobra.Command) (string, bool) {
|
|||||||
return content, true
|
return content, true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if description or body is "-" (read from stdin)
|
// Check if description, body, or message is "-" (read from stdin)
|
||||||
// This provides a convenient shorthand: --description=- instead of --body-file=-
|
// This provides a convenient shorthand: --description=- instead of --body-file=-
|
||||||
desc, _ := cmd.Flags().GetString("description")
|
desc, _ := cmd.Flags().GetString("description")
|
||||||
body, _ := cmd.Flags().GetString("body")
|
body, _ := cmd.Flags().GetString("body")
|
||||||
|
message, _ := cmd.Flags().GetString("message")
|
||||||
|
|
||||||
if desc == "-" || body == "-" {
|
if desc == "-" || body == "-" || message == "-" {
|
||||||
// Error if both are set to different values
|
// Error if multiple are set to different values
|
||||||
if descChanged && bodyChanged && desc != body {
|
values := make(map[string]string)
|
||||||
fmt.Fprintf(os.Stderr, "Error: cannot specify both --description and --body with different values\n")
|
if descChanged {
|
||||||
fmt.Fprintf(os.Stderr, " --description: %q\n", desc)
|
values["--description"] = desc
|
||||||
fmt.Fprintf(os.Stderr, " --body: %q\n", body)
|
}
|
||||||
|
if bodyChanged {
|
||||||
|
values["--body"] = body
|
||||||
|
}
|
||||||
|
if messageChanged {
|
||||||
|
values["--message"] = message
|
||||||
|
}
|
||||||
|
if len(values) > 1 {
|
||||||
|
var firstVal string
|
||||||
|
for _, v := range values {
|
||||||
|
if firstVal == "" {
|
||||||
|
firstVal = v
|
||||||
|
} else if v != firstVal {
|
||||||
|
fmt.Fprintf(os.Stderr, "Error: cannot specify multiple description flags with different values\n")
|
||||||
|
for flag, val := range values {
|
||||||
|
fmt.Fprintf(os.Stderr, " %s: %q\n", flag, val)
|
||||||
|
}
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
content, err := readBodyFile("-")
|
content, err := readBodyFile("-")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "Error reading from stdin: %v\n", err)
|
fmt.Fprintf(os.Stderr, "Error reading from stdin: %v\n", err)
|
||||||
@@ -88,20 +110,50 @@ func getDescriptionFlag(cmd *cobra.Command) (string, bool) {
|
|||||||
return content, true
|
return content, true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Error if both description and body are specified with different values
|
// Error if multiple description flags are specified with different values
|
||||||
if descChanged && bodyChanged {
|
changedCount := 0
|
||||||
if desc != body {
|
var firstVal string
|
||||||
fmt.Fprintf(os.Stderr, "Error: cannot specify both --description and --body with different values\n")
|
var firstFlag string
|
||||||
fmt.Fprintf(os.Stderr, " --description: %q\n", desc)
|
if descChanged {
|
||||||
|
changedCount++
|
||||||
|
firstVal = desc
|
||||||
|
firstFlag = "--description"
|
||||||
|
}
|
||||||
|
if bodyChanged {
|
||||||
|
changedCount++
|
||||||
|
if firstVal == "" {
|
||||||
|
firstVal = body
|
||||||
|
firstFlag = "--body"
|
||||||
|
} else if body != firstVal {
|
||||||
|
fmt.Fprintf(os.Stderr, "Error: cannot specify both %s and --body with different values\n", firstFlag)
|
||||||
|
fmt.Fprintf(os.Stderr, " %s: %q\n", firstFlag, firstVal)
|
||||||
fmt.Fprintf(os.Stderr, " --body: %q\n", body)
|
fmt.Fprintf(os.Stderr, " --body: %q\n", body)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if messageChanged {
|
||||||
|
changedCount++
|
||||||
|
if firstVal == "" {
|
||||||
|
firstVal = message
|
||||||
|
firstFlag = "--message"
|
||||||
|
} else if message != firstVal {
|
||||||
|
fmt.Fprintf(os.Stderr, "Error: cannot specify both %s and --message with different values\n", firstFlag)
|
||||||
|
fmt.Fprintf(os.Stderr, " %s: %q\n", firstFlag, firstVal)
|
||||||
|
fmt.Fprintf(os.Stderr, " --message: %q\n", message)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Return whichever was set (or description's value if neither)
|
// Return whichever was set (priority: description > body > message)
|
||||||
|
if descChanged {
|
||||||
|
return desc, true
|
||||||
|
}
|
||||||
if bodyChanged {
|
if bodyChanged {
|
||||||
return body, true
|
return body, true
|
||||||
}
|
}
|
||||||
|
if messageChanged {
|
||||||
|
return message, true
|
||||||
|
}
|
||||||
|
|
||||||
return desc, descChanged
|
return desc, descChanged
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user