add descriptive comment to variour commands
move completions to its own class
This commit is contained in:
@@ -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)")
|
||||
|
||||
Reference in New Issue
Block a user