Skip to content

Commit

Permalink
chore(deps): Upgrade urfave/cli to v2
Browse files Browse the repository at this point in the history
Co-authored-by: Étienne M. <[email protected]>
  • Loading branch information
aurelien-reeves-scalingo and EtienneM committed Aug 30, 2022
1 parent f45bfb0 commit a94b077
Show file tree
Hide file tree
Showing 174 changed files with 11,170 additions and 4,322 deletions.
5 changes: 3 additions & 2 deletions cmd/addon_providers_list.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cmd

import (
"github.com/urfave/cli"
"github.com/urfave/cli/v2"

"github.com/Scalingo/cli/addon_providers"
"github.com/Scalingo/cli/cmd/autocomplete"
Expand All @@ -13,10 +13,11 @@ var (
Category: "Addons - Global",
Description: "List all addons you can add to your app.",
Usage: "List all addons",
Action: func(c *cli.Context) {
Action: func(c *cli.Context) error {
if err := addon_providers.List(); err != nil {
errorQuit(err)
}
return nil
},
BashComplete: func(c *cli.Context) {
autocomplete.CmdFlagsAutoComplete(c, "addons-list")
Expand Down
47 changes: 26 additions & 21 deletions cmd/addons.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cmd

import (
"github.com/urfave/cli"
"github.com/urfave/cli/v2"

"github.com/Scalingo/cli/addons"
"github.com/Scalingo/cli/cmd/autocomplete"
Expand All @@ -13,16 +13,16 @@ var (
Name: "addons",
Category: "Addons",
Usage: "List used add-ons",
Flags: []cli.Flag{appFlag},
Flags: []cli.Flag{&appFlag},
Description: ` List all addons used by your app:
$ scalingo -a myapp addons
# See also 'addons-add' and 'addons-remove'
`,
Action: func(c *cli.Context) {
Action: func(c *cli.Context) error {
currentApp := detect.CurrentApp(c)
var err error
if len(c.Args()) == 0 {
if c.Args().Len() == 0 {
err = addons.List(currentApp)
} else {
cli.ShowCommandHelp(c, "addons")
Expand All @@ -31,6 +31,7 @@ var (
if err != nil {
errorQuit(err)
}
return nil
},
BashComplete: func(c *cli.Context) {
autocomplete.CmdFlagsAutoComplete(c, "addons")
Expand All @@ -39,24 +40,25 @@ var (
AddonsAddCommand = cli.Command{
Name: "addons-add",
Category: "Addons",
Flags: []cli.Flag{appFlag},
Flags: []cli.Flag{&appFlag},
Usage: "Provision an add-on for your application",
Description: ` Provision an add-on for your application:
$ scalingo -a myapp addons-add <addon-name> <plan>
# See also 'addons-list' and 'addons-plans'
`,
Action: func(c *cli.Context) {
Action: func(c *cli.Context) error {
currentApp := detect.CurrentApp(c)
var err error
if len(c.Args()) == 2 {
err = addons.Provision(currentApp, c.Args()[0], c.Args()[1])
if c.Args().Len() == 2 {
err = addons.Provision(currentApp, c.Args().First(), c.Args().Slice()[1])
} else {
cli.ShowCommandHelp(c, "addons-add")
}
if err != nil {
errorQuit(err)
}
return nil
},
BashComplete: func(c *cli.Context) {
autocomplete.CmdFlagsAutoComplete(c, "addons-add")
Expand All @@ -66,24 +68,25 @@ var (
AddonsRemoveCommand = cli.Command{
Name: "addons-remove",
Category: "Addons",
Flags: []cli.Flag{appFlag},
Flags: []cli.Flag{&appFlag},
Usage: "Remove an existing addon from your app",
Description: ` Remove an existing addon from your app:
$ scalingo -a myapp addons-remove <addon-id>
# See also 'addons' and 'addons-add'
`,
Action: func(c *cli.Context) {
Action: func(c *cli.Context) error {
currentApp := detect.CurrentApp(c)
var err error
if len(c.Args()) == 1 {
err = addons.Destroy(currentApp, c.Args()[0])
if c.Args().Len() == 1 {
err = addons.Destroy(currentApp, c.Args().First())
} else {
cli.ShowCommandHelp(c, "addons-remove")
}
if err != nil {
errorQuit(err)
}
return nil
},
BashComplete: func(c *cli.Context) {
autocomplete.CmdFlagsAutoComplete(c, "addons-remove")
Expand All @@ -93,24 +96,25 @@ var (
AddonsUpgradeCommand = cli.Command{
Name: "addons-upgrade",
Category: "Addons",
Flags: []cli.Flag{appFlag},
Flags: []cli.Flag{&appFlag},
Usage: "Upgrade or downgrade an add-on attached to your app",
Description: ` Upgrade an addon attached to your app:
$ scalingo -a myapp addons-upgrade <addon-id> <plan>
# See also 'addons-plans' and 'addons-remove'
`,
Action: func(c *cli.Context) {
Action: func(c *cli.Context) error {
currentApp := detect.CurrentApp(c)
var err error
if len(c.Args()) == 2 {
err = addons.Upgrade(currentApp, c.Args()[0], c.Args()[1])
if c.Args().Len() == 2 {
err = addons.Upgrade(currentApp, c.Args().First(), c.Args().Slice()[1])
} else {
cli.ShowCommandHelp(c, "addons-upgrade")
}
if err != nil {
errorQuit(err)
}
return nil
},
BashComplete: func(c *cli.Context) {
autocomplete.CmdFlagsAutoComplete(c, "addons-upgrade")
Expand All @@ -121,25 +125,26 @@ var (
Name: "addons-info",
Category: "Addons",
Usage: "Display information about an add-on attached to your app",
Flags: []cli.Flag{appFlag},
Flags: []cli.Flag{&appFlag},
Description: ` Display information about an add-on attached to your app:
$ scalingo --app my-app addons-info --addon <addon-id>
# See also 'addons' and 'addons-upgrade'
`,
Action: func(c *cli.Context) {
if len(c.Args()) != 1 {
Action: func(c *cli.Context) error {
if c.Args().Len() != 1 {
cli.ShowCommandHelp(c, "addons-info")
return
return nil
}

currentApp := detect.CurrentApp(c)
currentAddon := c.Args()[0]
currentAddon := c.Args().First()

err := addons.Info(currentApp, currentAddon)
if err != nil {
errorQuit(err)
}
return nil
},
BashComplete: func(c *cli.Context) {
autocomplete.CmdFlagsAutoComplete(c, "addons-info")
Expand Down
11 changes: 6 additions & 5 deletions cmd/addons_providers_plans_list.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cmd

import (
"github.com/urfave/cli"
"github.com/urfave/cli/v2"

"github.com/Scalingo/cli/addon_providers"
"github.com/Scalingo/cli/cmd/autocomplete"
Expand All @@ -13,14 +13,15 @@ var (
Category: "Addons - Global",
Description: "List the plans for an addon.\n Example:\n scalingo addon-plans scalingo-mongodb",
Usage: "List plans",
Action: func(c *cli.Context) {
if len(c.Args()) != 1 {
Action: func(c *cli.Context) error {
if c.Args().Len() != 1 {
cli.ShowCommandHelp(c, "addons-plans")
return
return nil
}
if err := addon_providers.Plans(c.Args()[0]); err != nil {
if err := addon_providers.Plans(c.Args().First()); err != nil {
errorQuit(err)
}
return nil
},
BashComplete: func(c *cli.Context) {
autocomplete.AddonsPlansAutoComplete(c)
Expand Down
Loading

0 comments on commit a94b077

Please sign in to comment.