-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from asdf-vm/tb/plugin-command-placeholders
feat(golang-rewrite): add placeholders for plugin subcommands
- Loading branch information
Showing
3 changed files
with
77 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,83 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"os" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/urfave/cli/v2" | ||
) | ||
|
||
var rootCmd = &cobra.Command{ | ||
Use: "asdf", | ||
Short: "The multiple runtime version manager", | ||
Long: `The Multiple Runtime Version Manager. | ||
const usageText = `The Multiple Runtime Version Manager. | ||
Manage all your runtime versions with one tool! | ||
Complete documentation is available at https://asdf-vm.com/`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
// TODO: Flesh this out | ||
fmt.Println("Late but latest -- Rajinikanth") | ||
}, | ||
} | ||
Complete documentation is available at https://asdf-vm.com/` | ||
|
||
func init() { | ||
// TODO: Add flags relevant to all commands | ||
//rootCmd.PersistentFlags().BoolVarP(&Verbose, "verbose", "v", false, "verbose output") | ||
func Execute() { | ||
app := &cli.App{ | ||
Name: "asdf", | ||
Version: "0.1.0", | ||
// Not really sure what I should put here, but all the new Golang code will | ||
// likely be written by me. | ||
Copyright: "(c) 2024 Trevor Brown", | ||
Authors: []*cli.Author{ | ||
&cli.Author{ | ||
Name: "Trevor Brown", | ||
}, | ||
}, | ||
Usage: "The multiple runtime version manager", | ||
UsageText: usageText, | ||
Commands: []*cli.Command{ | ||
// TODO: Flesh out all these commands | ||
&cli.Command{ | ||
Name: "plugin", | ||
Action: func(cCtx *cli.Context) error { | ||
log.Print("Foobar") | ||
return nil | ||
}, | ||
Subcommands: []*cli.Command{ | ||
&cli.Command{ | ||
Name: "add", | ||
Action: func(cCtx *cli.Context) error { | ||
log.Print("Baz") | ||
return nil | ||
}, | ||
}, | ||
&cli.Command{ | ||
Name: "list", | ||
Action: func(cCtx *cli.Context) error { | ||
log.Print("Bim") | ||
return nil | ||
}, | ||
}, | ||
&cli.Command{ | ||
Name: "Lorem", | ||
Action: func(cCtx *cli.Context) error { | ||
log.Print("Foobar") | ||
return nil | ||
}, | ||
}, | ||
&cli.Command{ | ||
Name: "update", | ||
Action: func(cCtx *cli.Context) error { | ||
log.Print("Ipsum") | ||
return nil | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
Action: func(cCtx *cli.Context) error { | ||
// TODO: flesh this out | ||
log.Print("Late but latest -- Rajinikanth") | ||
return nil | ||
}, | ||
} | ||
|
||
// TODO: Add sub commands | ||
//rootCmd.AddCommand(pluginCmd) | ||
} | ||
err := app.Run(os.Args) | ||
|
||
func Execute() { | ||
if err := rootCmd.Execute(); err != nil { | ||
fmt.Println(err) | ||
if err != nil { | ||
os.Exit(1) | ||
log.Fatal(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters