add descriptive comment to variour commands

move completions to its own class
This commit is contained in:
Robin Olsen
2026-02-07 12:15:09 +01:00
parent 9baedea9b5
commit 6bf8b76aab
5 changed files with 82 additions and 52 deletions

View File

@@ -9,6 +9,7 @@ import (
"github.com/spf13/cobra"
)
// Variables to hold flag values for the create command.
var (
createDescription string
createStatus string
@@ -21,6 +22,7 @@ const (
pm create Fix bug --desc "Bug description" --status in_progress --type bug --priority 5`
)
// createCmd represents the create command, which allows users to create a new issue with specified details.
var createCmd = &cobra.Command{
Use: "create [title]",
Short: "Create a new issue",
@@ -32,6 +34,7 @@ var createCmd = &cobra.Command{
RunE: runCreateCmd,
}
// runCreateCmd executes the create command logic,
func runCreateCmd(cmd *cobra.Command, args []string) error {
createTitle := strings.Join(args, " ")
@@ -47,11 +50,13 @@ func runCreateCmd(cmd *cobra.Command, args []string) error {
Priority: createPriority,
}
// Create the issue using the service layer.
err := svc.Beads.CreateIssue(cmd.Context(), issue, "test_actor")
if err != nil {
return fmt.Errorf("error creating issue: %w", err)
}
// Build the output string with the created issue details.
str := fmt.Sprintf("Created issue with ID: %s\n", issue.ID)
if issue.Title != "" {
@@ -74,11 +79,12 @@ func runCreateCmd(cmd *cobra.Command, args []string) error {
str += fmt.Sprintf("Priority: %d\n", issue.Priority)
}
fmt.Print(str)
cmd.Print(str)
return nil
}
// init function to set up the create command and its flags.
func init() {
createCmd.Flags().StringVarP(&createDescription, "desc", "d", "", "Issue description")
createCmd.Flags().StringVarP(&createStatus, "status", "s", "open", "Issue status(open, closed, in_progress)")