@@ -49,23 +49,43 @@ func NewCmdCreate(f *cmdutil.Factory, runF func(*CreateOptions) error) *cobra.Co
4949 cmd := & cobra.Command {
5050 Use : "create [<name>]" ,
5151 Short : "Create a new repository" ,
52- Long : `Create a new GitHub repository.` ,
53- Args : cobra .MaximumNArgs (1 ),
52+ Long : heredoc .Docf (`
53+ Create a new GitHub repository.
54+
55+ When the current directory is a local git repository, the new repository will be added
56+ as the "origin" git remote. Otherwise, the command will prompt to clone the new
57+ repository into a sub-directory.
58+
59+ To create a repository non-interactively, supply the following:
60+ - the name argument;
61+ - the %[1]s--confirm%[1]s flag;
62+ - one of %[1]s--public%[1]s, %[1]s--private%[1]s, or %[1]s--internal%[1]s.
63+
64+ To toggle off %[1]s--enable-issues%[1]s or %[1]s--enable-wiki%[1]s, which are enabled
65+ by default, use the %[1]s--enable-issues=false%[1]s syntax.
66+ ` , "`" ),
67+ Args : cobra .MaximumNArgs (1 ),
5468 Example : heredoc .Doc (`
5569 # create a repository under your account using the current directory name
70+ $ git init my-project
71+ $ cd my-project
5672 $ gh repo create
5773
5874 # create a repository with a specific name
5975 $ gh repo create my-project
6076
6177 # create a repository in an organization
6278 $ gh repo create cli/my-project
79+
80+ # disable issues and wiki
81+ $ gh repo create --enable-issues=false --enable-wiki=false
6382 ` ),
6483 Annotations : map [string ]string {
65- "help:arguments" : heredoc .Doc (
66- `A repository can be supplied as an argument in any of the following formats:
67- - <OWNER/REPO>
68- - by URL, e.g. "https://github.com/OWNER/REPO"` ),
84+ "help:arguments" : heredoc .Doc (`
85+ A repository can be supplied as an argument in any of the following formats:
86+ - "OWNER/REPO"
87+ - by URL, e.g. "https://github.com/OWNER/REPO"
88+ ` ),
6989 },
7090 RunE : func (cmd * cobra.Command , args []string ) error {
7191 if len (args ) > 0 {
@@ -78,32 +98,31 @@ func NewCmdCreate(f *cmdutil.Factory, runF func(*CreateOptions) error) *cobra.Co
7898 }
7999
80100 if ! opts .Internal && ! opts .Private && ! opts .Public {
81- return & cmdutil.FlagError {Err : errors .New ("--public, --private, or --internal required when not running interactively" )}
101+ return & cmdutil.FlagError {Err : errors .New ("` --public`, ` --private` , or ` --internal` required when not running interactively" )}
82102 }
83103 }
84104
85- if runF != nil {
86- return runF ( opts )
105+ if opts . Template != "" && ( opts . Homepage != "" || opts . Team != "" || cmd . Flags (). Changed ( "enable-issues" ) || cmd . Flags (). Changed ( "enable-wiki" )) {
106+ return & cmdutil. FlagError { Err : errors . New ( "The `--template` option is not supported with `--homepage`, `--team`, `--enable-issues`, or `--enable-wiki`" )}
87107 }
88108
89- if opts . Template != "" && ( opts . Homepage != "" || opts . Team != "" || ! opts . EnableIssues || ! opts . EnableWiki ) {
90- return & cmdutil. FlagError { Err : errors . New ( `The '--template' option is not supported with '--homepage, --team, --enable-issues or --enable-wiki'` )}
109+ if runF != nil {
110+ return runF ( opts )
91111 }
92-
93112 return createRun (opts )
94113 },
95114 }
96115
97- cmd .Flags ().StringVarP (& opts .Description , "description" , "d" , "" , "Description of repository" )
98- cmd .Flags ().StringVarP (& opts .Homepage , "homepage" , "h" , "" , "Repository home page URL" )
99- cmd .Flags ().StringVarP (& opts .Team , "team" , "t" , "" , "The name of the organization team to be granted access" )
100- cmd .Flags ().StringVarP (& opts .Template , "template" , "p" , "" , "Make the new repository based on a template repository" )
116+ cmd .Flags ().StringVarP (& opts .Description , "description" , "d" , "" , "Description of the repository" )
117+ cmd .Flags ().StringVarP (& opts .Homepage , "homepage" , "h" , "" , "Repository home page ` URL` " )
118+ cmd .Flags ().StringVarP (& opts .Team , "team" , "t" , "" , "The ` name` of the organization team to be granted access" )
119+ cmd .Flags ().StringVarP (& opts .Template , "template" , "p" , "" , "Make the new repository based on a template ` repository` " )
101120 cmd .Flags ().BoolVar (& opts .EnableIssues , "enable-issues" , true , "Enable issues in the new repository" )
102121 cmd .Flags ().BoolVar (& opts .EnableWiki , "enable-wiki" , true , "Enable wiki in the new repository" )
103122 cmd .Flags ().BoolVar (& opts .Public , "public" , false , "Make the new repository public" )
104123 cmd .Flags ().BoolVar (& opts .Private , "private" , false , "Make the new repository private" )
105124 cmd .Flags ().BoolVar (& opts .Internal , "internal" , false , "Make the new repository internal" )
106- cmd .Flags ().BoolVarP (& opts .ConfirmSubmit , "confirm" , "y" , false , "Confirm the submission directly " )
125+ cmd .Flags ().BoolVarP (& opts .ConfirmSubmit , "confirm" , "y" , false , "Skip the confirmation prompt " )
107126
108127 return cmd
109128}
@@ -139,7 +158,7 @@ func createRun(opts *CreateOptions) error {
139158 }
140159
141160 if enabledFlagCount > 1 {
142- return fmt .Errorf ("expected exactly one of --public, --private, or --internal to be true" )
161+ return fmt .Errorf ("expected exactly one of ` --public`, ` --private` , or ` --internal` to be true" )
143162 } else if enabledFlagCount == 1 {
144163 isVisibilityPassed = true
145164 }
0 commit comments