| 66 | } |
| 67 | |
| 68 | func NewCmdCreate(f *cmdutil.Factory, runF func(*CreateOptions) error) *cobra.Command { |
| 69 | opts := &CreateOptions{ |
| 70 | IO: f.IOStreams, |
| 71 | HttpClient: f.HttpClient, |
| 72 | GitClient: f.GitClient, |
| 73 | Config: f.Config, |
| 74 | Prompter: f.Prompter, |
| 75 | } |
| 76 | |
| 77 | var enableIssues bool |
| 78 | var enableWiki bool |
| 79 | |
| 80 | cmd := &cobra.Command{ |
| 81 | Use: "create [<name>]", |
| 82 | Short: "Create a new repository", |
| 83 | Long: heredoc.Docf(` |
| 84 | Create a new GitHub repository. |
| 85 | |
| 86 | To create a repository interactively, use %[1]sgh repo create%[1]s with no arguments. |
| 87 | |
| 88 | To create a remote repository non-interactively, supply the repository name and one of %[1]s--public%[1]s, %[1]s--private%[1]s, or %[1]s--internal%[1]s. |
| 89 | Pass %[1]s--clone%[1]s to clone the new repository locally. |
| 90 | |
| 91 | If the %[1]sOWNER/%[1]s portion of the %[1]sOWNER/REPO%[1]s name argument is omitted, it |
| 92 | defaults to the name of the authenticating user. |
| 93 | |
| 94 | To create a remote repository from an existing local repository, specify the source directory with %[1]s--source%[1]s. |
| 95 | By default, the remote repository name will be the name of the source directory. |
| 96 | |
| 97 | Pass %[1]s--push%[1]s to push any local commits to the new repository. If the repo is bare, this will mirror all refs. |
| 98 | |
| 99 | For language or platform .gitignore templates to use with %[1]s--gitignore%[1]s, <https://github.com/github/gitignore>. |
| 100 | |
| 101 | For license keywords to use with %[1]s--license%[1]s, run %[1]sgh repo license list%[1]s or visit <https://choosealicense.com>. |
| 102 | |
| 103 | The repo is created with the configured repository default branch, see <https://docs.github.com/en/account-and-profile/setting-up-and-managing-your-personal-account-on-github/managing-user-account-settings/managing-the-default-branch-name-for-your-repositories>. |
| 104 | `, "`"), |
| 105 | Example: heredoc.Doc(` |
| 106 | # Create a repository interactively |
| 107 | $ gh repo create |
| 108 | |
| 109 | # Create a new remote repository and clone it locally |
| 110 | $ gh repo create my-project --public --clone |
| 111 | |
| 112 | # Create a new remote repository in a different organization |
| 113 | $ gh repo create my-org/my-project --public |
| 114 | |
| 115 | # Create a remote repository from the current directory |
| 116 | $ gh repo create my-project --private --source=. --remote=upstream |
| 117 | `), |
| 118 | Args: cobra.MaximumNArgs(1), |
| 119 | Aliases: []string{"new"}, |
| 120 | RunE: func(cmd *cobra.Command, args []string) error { |
| 121 | if len(args) > 0 { |
| 122 | opts.Name = args[0] |
| 123 | } |
| 124 | |
| 125 | if len(args) == 0 && cmd.Flags().NFlag() == 0 { |