Skip to content

Commit

Permalink
Most frequently used sub-compposer commands.
Browse files Browse the repository at this point in the history
  • Loading branch information
abhisekmazumdar committed Mar 30, 2023
1 parent b59e604 commit 65f8f52
Showing 1 changed file with 33 additions and 3 deletions.
36 changes: 33 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,16 @@ func main() {
Name: "create-project",
Usage: "runs as ddev/lando composer create-project ...",
Action: func(cCtx *cli.Context) error {
fmt.Println("Run composer require: ", cCtx.Args().First())
cmdComposerBased("create-project ", cCtx)
return nil
},
},
{
Name: "install",
Aliases: []string{"i"},
Usage: "runs as ddev/lando composer install ...",
Action: func(cCtx *cli.Context) error {
cmdComposerBased("install ", cCtx)
return nil
},
},
Expand All @@ -42,7 +51,16 @@ func main() {
Aliases: []string{"r"},
Usage: "runs as ddev/lando composer require ...",
Action: func(cCtx *cli.Context) error {
fmt.Println("Run composer require: ", cCtx.Args().First())
cmdComposerBased("require ", cCtx)
return nil
},
},
{
Name: "update",
Aliases: []string{"u"},
Usage: "runs as ddev/lando composer update ...",
Action: func(cCtx *cli.Context) error {
cmdComposerBased("update ", cCtx)
return nil
},
},
Expand Down Expand Up @@ -86,7 +104,7 @@ func cmdComposer(cCtx *cli.Context) error {

}

// Handle any drush which has drush as first argument.
// Handle any command which has drush as first argument.
func cmdDrush(cCtx *cli.Context) error {

devTool, strArgs := helper(cCtx)
Expand All @@ -96,6 +114,18 @@ func cmdDrush(cCtx *cli.Context) error {

}

// Handle any command which has is a composer's as second argument.
func cmdComposerBased(subCmd string, cCtx *cli.Context) error {

devTool, strArgs := helper(cCtx)
cmd := "composer " + subCmd + strArgs

runner.Run(devTool, cmd)

return nil

}

// Helper for all commands.
func helper(cCtx *cli.Context) (string, string) {

Expand Down

0 comments on commit 65f8f52

Please sign in to comment.