@@ -129,8 +129,9 @@ func NewGitSourceCreateCommand() *cobra.Command {
129129 )
130130
131131 cmd := & cobra.Command {
132- Use : "create runtime_name git-source_name" ,
133- Short : "add a new git-source to an existing runtime" ,
132+ Use : "create RUNTIME_NAME GITSOURCE_NAME" ,
133+ Short : "Adds a new git-source to an existing runtime" ,
134+ Args : cobra .MaximumNArgs (2 ),
134135 Example : util .Doc (`
135136 <BIN> git-source create runtime_name git-source-name --git-src-repo https://github.com/owner/repo-name/my-workflow
136137 ` ),
@@ -228,7 +229,7 @@ func RunGitSourceCreate(ctx context.Context, opts *GitSourceCreateOptions) error
228229 if err := appDef .CreateApp (ctx , nil , opts .InsCloneOpts , opts .RuntimeName , store .Get ().CFGitSourceType , opts .Include , "" ); err != nil {
229230 return fmt .Errorf ("failed to create git-source application. Err: %w" , err )
230231 }
231-
232+
232233 log .G (ctx ).Infof ("Successfully created git-source: '%s'" , opts .GsName )
233234
234235 return nil
@@ -264,7 +265,7 @@ func createDemoResources(ctx context.Context, opts *GitSourceCreateOptions, gsRe
264265 commitMsg := fmt .Sprintf ("Created demo pipelines in %s Directory" , opts .GsCloneOpts .Path ())
265266
266267 log .G (ctx ).Info ("Pushing demo pipelines to the new git-source repo" )
267-
268+
268269 if err := apu .PushWithMessage (ctx , gsRepo , commitMsg ); err != nil {
269270 return fmt .Errorf ("failed to push demo pipelines to git-source repo: %w" , err )
270271 }
@@ -280,7 +281,7 @@ func createPlaceholderIfNeeded(ctx context.Context, opts *GitSourceCreateOptions
280281 }
281282
282283 if len (fi ) == 0 {
283- if err = billyUtils .WriteFile (gsFs , "DUMMY" , []byte {}, 0666 ); err != nil {
284+ if err = billyUtils .WriteFile (gsFs , "DUMMY" , []byte {}, 0666 ); err != nil {
284285 return fmt .Errorf ("failed to write the git-source placeholder file. Err: %w" , err )
285286 }
286287
@@ -434,18 +435,16 @@ func createCronExampleTrigger() (*sensorsv1alpha1.Trigger, error) {
434435
435436func NewGitSourceListCommand () * cobra.Command {
436437 cmd := & cobra.Command {
437- Use : "list runtime_name " ,
438+ Use : "list RUNTIME_NAME " ,
438439 Short : "List all Codefresh git-sources of a given runtime" ,
440+ Args : cobra .MaximumNArgs (1 ),
439441 Example : util .Doc (`<BIN> git-source list my-runtime` ),
440- PreRun : func (cmd * cobra.Command , args []string ) {
442+ RunE : func (cmd * cobra.Command , args []string ) error {
441443 if len (args ) < 1 {
442- log . G ( cmd . Context ()). Fatal ("must enter runtime name" )
444+ return fmt . Errorf ("must enter runtime name" )
443445 }
444- },
445- RunE : func (cmd * cobra.Command , args []string ) error {
446- ctx := cmd .Context ()
447446
448- return RunGitSourceList (ctx , args [0 ])
447+ return RunGitSourceList (cmd . Context () , args [0 ])
449448 },
450449 }
451450 return cmd
@@ -514,21 +513,21 @@ func NewGitSourceDeleteCommand() *cobra.Command {
514513 )
515514
516515 cmd := & cobra.Command {
517- Use : "delete runtime_name git-source_name " ,
516+ Use : "delete RUNTIME_NAME GITSOURCE_NAME " ,
518517 Short : "delete a git-source from a runtime" ,
518+ Args : cobra .MaximumNArgs (2 ),
519519 Example : util .Doc (`
520520 <BIN> git-source delete runtime_name git-source_name
521521 ` ),
522522 PreRunE : func (cmd * cobra.Command , args []string ) error {
523- ctx := cmd .Context ()
524523 store .Get ().Silent = true
525524
526525 if len (args ) < 1 {
527- log . G ( ctx ). Fatal ("must enter runtime name" )
526+ return fmt . Errorf ("must enter runtime name" )
528527 }
529528
530529 if len (args ) < 2 {
531- log . G ( ctx ). Fatal ("must enter git-source name" )
530+ return fmt . Errorf ("must enter git-source name" )
532531 }
533532
534533 err := ensureRepo (cmd , args [0 ], insCloneOpts , true )
@@ -580,25 +579,25 @@ func NewGitSourceEditCommand() *cobra.Command {
580579 )
581580
582581 cmd := & cobra.Command {
583- Use : "edit runtime_name git-source_name " ,
582+ Use : "edit RUNTIME_NAME GITSOURCE_NAME " ,
584583 Short : "edit a git-source of a runtime" ,
584+ Args : cobra .MaximumNArgs (2 ),
585585 Example : util .Doc (`
586- <BIN> git-source edit runtime_name git-source_name --git-src-repo https://github.com/owner/repo-name/my-workflow
586+ <BIN> git-source edit runtime_name git-source_name --git-src-repo https://github.com/owner/repo-name.git/path/to/dir
587587 ` ),
588588 PreRunE : func (cmd * cobra.Command , args []string ) error {
589- ctx := cmd .Context ()
590589 store .Get ().Silent = true
591590
592591 if len (args ) < 1 {
593- log . G ( ctx ). Fatal ("must enter a runtime name" )
592+ return fmt . Errorf ("must enter a runtime name" )
594593 }
595594
596595 if len (args ) < 2 {
597- log . G ( ctx ). Fatal ("must enter a git-source name" )
596+ return fmt . Errorf ("must enter a git-source name" )
598597 }
599598
600599 if gsCloneOpts .Repo == "" {
601- log . G ( ctx ). Fatal ( "must enter a valid value to --git-src-repo. Example: https://github.com/owner/repo-name/path/to/workflow " )
600+ return fmt . Errorf ( "must enter a valid value to --git-src-repo. Example: https://github.com/owner/repo-name.git /path/to/dir " )
602601 }
603602
604603 err := ensureRepo (cmd , args [0 ], insCloneOpts , true )
0 commit comments