refactor to make cli better and simplify the code
This commit is contained in:
@@ -14,6 +14,7 @@ var CloseCmd = &cobra.Command{
|
||||
Short: "Close an existing issue",
|
||||
Long: `Close an existing issue by its ID.`,
|
||||
Example: `pm close pm-abc`,
|
||||
|
||||
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: runCloseCmd,
|
||||
|
||||
@@ -20,7 +20,7 @@ pm comment ISSUE-1 LGTM --author alice
|
||||
pm comment ISSUE-1 -m "Needs review"`
|
||||
|
||||
var CommentCmd = &cobra.Command{
|
||||
Use: "comment [issue ID] [message...]",
|
||||
Use: "comment [id] [message...]",
|
||||
Short: "Add a comment on an issue",
|
||||
Long: `Add a comment on an issue by ID. All arguments after the issue ID form the message (no quotes needed), or use --message.`,
|
||||
Example: commentCmdExample,
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
// CommentsCmd represents the command to list comments on an issue.
|
||||
var CommentsCmd = &cobra.Command{
|
||||
Use: "comments [issue ID]",
|
||||
Use: "comments [id]",
|
||||
Short: "List comments on an issue",
|
||||
Long: `List all comments on an issue by ID.`,
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ pm create Fix bug --desc "Bug description" --status in_progress --type bug --pri
|
||||
|
||||
// CreateCmd represents the create command, which allows users to create a new issue with specified details.
|
||||
var CreateCmd = &cobra.Command{
|
||||
Use: "create [title]",
|
||||
Use: "create [title...]",
|
||||
Short: "Create a new issue",
|
||||
Long: `Create a new issue with the specified details.`,
|
||||
Example: createCmdExample,
|
||||
|
||||
@@ -20,7 +20,7 @@ pm list -p 1 -l 10`
|
||||
|
||||
// ListCmd represents the get issues command.
|
||||
var ListCmd = &cobra.Command{
|
||||
Use: "list [search query]",
|
||||
Use: "list [query]",
|
||||
Short: "List all issues",
|
||||
Long: `List all issues in the project management system.`,
|
||||
Example: lsExamples,
|
||||
|
||||
@@ -7,13 +7,13 @@ import (
|
||||
|
||||
// GetCmd represents the get issue command.
|
||||
var GetCmd = &cobra.Command{
|
||||
Use: "describe [issue ID]",
|
||||
Use: "read [id]",
|
||||
Short: "Get issue details",
|
||||
Long: `Get issue details by ID`,
|
||||
|
||||
ValidArgsFunction: completeIssues,
|
||||
|
||||
Aliases: []string{"get", "read"},
|
||||
Aliases: []string{"get", "describe", "details"},
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: runGetCmd,
|
||||
}
|
||||
|
||||
@@ -85,11 +85,3 @@ func ExecuteArgsStringWithContext(ctx context.Context, args []string) (string, e
|
||||
|
||||
return buf.String(), err
|
||||
}
|
||||
|
||||
// init function to set up the command hierarchy and options.
|
||||
func init() {
|
||||
RootCmd.CompletionOptions.DisableDefaultCmd = false
|
||||
RootCmd.AddGroup(&cobra.Group{ID: "help", Title: "Helping Commands"})
|
||||
RootCmd.SetCompletionCommandGroupID("help")
|
||||
RootCmd.SetHelpCommandGroupID("help")
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
var updateFlags Flags
|
||||
|
||||
var UpdateCmd = &cobra.Command{
|
||||
Use: "update [issue ID]",
|
||||
Use: "update [id]",
|
||||
Short: "Update an existing issue",
|
||||
Long: `Update an existing issue by its ID with the specified details.`,
|
||||
Example: `pm update pm-001 --title "New title" -d "Description" -s in_progress --type task -p 3`,
|
||||
|
||||
Reference in New Issue
Block a user