NewProjectNewCommand creates the "project new" subcommand
()
| 58 | |
| 59 | // NewProjectNewCommand creates the "project new" subcommand |
| 60 | func NewProjectNewCommand() *cobra.Command { |
| 61 | cmd := &cobra.Command{ |
| 62 | Use: "new <title>", |
| 63 | Short: "Create a new GitHub Project V2 board", |
| 64 | Long: `Create a new GitHub Project V2 board owned by a user or organization. |
| 65 | |
| 66 | The project can optionally be linked to a specific repository. |
| 67 | |
| 68 | Authentication Requirements: |
| 69 | The default GITHUB_TOKEN cannot create projects. You must use additional authentication. |
| 70 | See https://github.github.com/gh-aw/reference/auth-projects/. |
| 71 | |
| 72 | Project Setup: |
| 73 | Use --with-project-setup to automatically create: |
| 74 | - Standard views (Progress Board, Task Tracker, Roadmap) |
| 75 | - Custom fields (Tracker Id, Worker Workflow, Target Repo, Priority, Size, dates) |
| 76 | - Enhanced Status field with "Review Required" option`, |
| 77 | Example: ` gh aw project new "My Project" --owner @me # Create user project |
| 78 | gh aw project new "Team Board" --owner myorg # Create org project |
| 79 | gh aw project new "Bugs" --owner myorg --link myorg/myrepo # Create and link to repo |
| 80 | gh aw project new "Project Q1" --owner myorg --with-project-setup # With project setup`, |
| 81 | Args: cobra.ExactArgs(1), |
| 82 | RunE: func(cmd *cobra.Command, args []string) error { |
| 83 | owner, _ := cmd.Flags().GetString("owner") |
| 84 | link, _ := cmd.Flags().GetString("link") |
| 85 | verbose, _ := cmd.Flags().GetBool("verbose") |
| 86 | withProjectSetup, _ := cmd.Flags().GetBool("with-project-setup") |
| 87 | |
| 88 | if owner == "" { |
| 89 | return errors.New("--owner flag is required. Use '@me' for current user or specify org name") |
| 90 | } |
| 91 | |
| 92 | config := ProjectConfig{ |
| 93 | Title: args[0], |
| 94 | Owner: owner, |
| 95 | Repo: link, |
| 96 | Verbose: verbose, |
| 97 | WithProjectSetup: withProjectSetup, |
| 98 | } |
| 99 | |
| 100 | return RunProjectNew(cmd.Context(), config) |
| 101 | }, |
| 102 | } |
| 103 | |
| 104 | cmd.Flags().String("owner", "", "Project owner: '@me' for current user or organization name (required)") |
| 105 | cmd.Flags().StringP("link", "l", "", "Repository to link project to (format: owner/repo)") |
| 106 | cmd.Flags().Bool("with-project-setup", false, "Create standard project views and custom fields") |
| 107 | _ = cmd.MarkFlagRequired("owner") |
| 108 | |
| 109 | return cmd |
| 110 | } |
| 111 | |
| 112 | // RunProjectNew executes the project creation logic |
| 113 | func RunProjectNew(ctx context.Context, config ProjectConfig) error { |