forked from toolshed/abra
		
	refactor!: migrate to urfave/cli v1
Better flexible flags handling.
This commit is contained in:
		
							
								
								
									
										30
									
								
								cli/cli.go
									
									
									
									
									
								
							
							
						
						
									
										30
									
								
								cli/cli.go
									
									
									
									
									
								
							@ -16,16 +16,15 @@ import (
 | 
			
		||||
	"coopcloud.tech/abra/cli/server"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/config"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/web"
 | 
			
		||||
	logrusStack "github.com/Gurpartap/logrus-stack"
 | 
			
		||||
	"github.com/sirupsen/logrus"
 | 
			
		||||
	"github.com/urfave/cli/v2"
 | 
			
		||||
	"github.com/urfave/cli"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// AutoCompleteCommand helps people set up auto-complete in their shells
 | 
			
		||||
var AutoCompleteCommand = &cli.Command{
 | 
			
		||||
var AutoCompleteCommand = cli.Command{
 | 
			
		||||
	Name:    "autocomplete",
 | 
			
		||||
	Usage:   "Configure shell autocompletion (recommended)",
 | 
			
		||||
	Aliases: []string{"ac"},
 | 
			
		||||
	Usage:   "Configure shell autocompletion (recommended)",
 | 
			
		||||
	Description: `
 | 
			
		||||
This command helps set up autocompletion in your shell by downloading the
 | 
			
		||||
relevant autocompletion files and laying out what additional information must
 | 
			
		||||
@ -43,6 +42,10 @@ Supported shells are as follows:
 | 
			
		||||
 | 
			
		||||
`,
 | 
			
		||||
	ArgsUsage: "<shell>",
 | 
			
		||||
	Flags: []cli.Flag{
 | 
			
		||||
		internal.DebugFlag,
 | 
			
		||||
		internal.NoInputFlag,
 | 
			
		||||
	},
 | 
			
		||||
	Action: func(c *cli.Context) error {
 | 
			
		||||
		shellType := c.Args().First()
 | 
			
		||||
 | 
			
		||||
@ -105,10 +108,10 @@ echo "PROG=abra\n_CLI_ZSH_AUTOCOMPLETE_HACK=1\nsource /etc/zsh/completion.d/abra
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// UpgradeCommand upgrades abra in-place.
 | 
			
		||||
var UpgradeCommand = &cli.Command{
 | 
			
		||||
var UpgradeCommand = cli.Command{
 | 
			
		||||
	Name:    "upgrade",
 | 
			
		||||
	Usage:   "Upgrade Abra itself",
 | 
			
		||||
	Aliases: []string{"u"},
 | 
			
		||||
	Usage:   "Upgrade Abra itself",
 | 
			
		||||
	Description: `
 | 
			
		||||
This command allows you to upgrade Abra in-place with the latest stable or
 | 
			
		||||
release candidate.
 | 
			
		||||
@ -150,7 +153,7 @@ func newAbraApp(version, commit string) *cli.App {
 | 
			
		||||
                         |_|
 | 
			
		||||
`,
 | 
			
		||||
		Version: fmt.Sprintf("%s-%s", version, commit[:7]),
 | 
			
		||||
		Commands: []*cli.Command{
 | 
			
		||||
		Commands: []cli.Command{
 | 
			
		||||
			app.AppCommand,
 | 
			
		||||
			server.ServerCommand,
 | 
			
		||||
			recipe.RecipeCommand,
 | 
			
		||||
@ -159,11 +162,7 @@ func newAbraApp(version, commit string) *cli.App {
 | 
			
		||||
			UpgradeCommand,
 | 
			
		||||
			AutoCompleteCommand,
 | 
			
		||||
		},
 | 
			
		||||
		Flags: []cli.Flag{
 | 
			
		||||
			internal.DebugFlag,
 | 
			
		||||
			internal.NoInputFlag,
 | 
			
		||||
		},
 | 
			
		||||
		Authors: []*cli.Author{
 | 
			
		||||
		Authors: []cli.Author{
 | 
			
		||||
			// If you're looking at this and you hack on Abra and you're not listed
 | 
			
		||||
			// here, please do add yourself! This is a community project, let's show
 | 
			
		||||
			// some love
 | 
			
		||||
@ -178,13 +177,6 @@ func newAbraApp(version, commit string) *cli.App {
 | 
			
		||||
	app.EnableBashCompletion = true
 | 
			
		||||
 | 
			
		||||
	app.Before = func(c *cli.Context) error {
 | 
			
		||||
		if internal.Debug {
 | 
			
		||||
			logrus.SetLevel(logrus.DebugLevel)
 | 
			
		||||
			logrus.SetFormatter(&logrus.TextFormatter{})
 | 
			
		||||
			logrus.SetOutput(os.Stderr)
 | 
			
		||||
			logrus.AddHook(logrusStack.StandardHook())
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		paths := []string{
 | 
			
		||||
			config.ABRA_DIR,
 | 
			
		||||
			path.Join(config.SERVERS_DIR),
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user