Skip to content

Commit

Permalink
refactor(autok3s): rename get command to list command
Browse files Browse the repository at this point in the history
Signed-off-by: Jason-ZW <zhenyang@rancher.com>
  • Loading branch information
rancher-sy-bot committed Sep 25, 2020
1 parent e133793 commit e3ca4b2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ By default, one worker will be created, and the number can be changed by `--work
### List K3s Clusters
This command will list the clusters that you have created on this machine.
```
sudo autok3s get cluster
sudo autok3s list
```

### Access K3s Cluster
Expand Down
23 changes: 9 additions & 14 deletions cmd/get.go → cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,21 @@ import (
)

var (
getCmd = &cobra.Command{
Use: "get",
Short: "Display one or many resources",
ValidArgs: []string{"cluster"},
Args: cobra.ExactArgs(1),
Example: ` autok3s get cluster`,
listCmd = &cobra.Command{
Use: "list",
Short: "List K3s clusters",
Example: ` autok3s list`,
}
)

func GetCommand() *cobra.Command {
getCmd.Run = func(cmd *cobra.Command, args []string) {
switch args[0] {
case "cluster":
getCluster()
}
func ListCommand() *cobra.Command {
listCmd.Run = func(cmd *cobra.Command, args []string) {
listCluster()
}
return getCmd
return listCmd
}

func getCluster() {
func listCluster() {
table := tablewriter.NewWriter(os.Stdout)
table.SetBorder(false)
table.SetHeaderLine(false)
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func main() {

rootCmd := cmd.Command()
rootCmd.AddCommand(cmd.CompletionCommand(), cmd.VersionCommand(gitVersion, gitCommit, gitTreeState, buildDate),
cmd.GetCommand(), cmd.CreateCommand(), cmd.JoinCommand(), cmd.KubectlCommand())
cmd.ListCommand(), cmd.CreateCommand(), cmd.JoinCommand(), cmd.KubectlCommand())

if err := rootCmd.Execute(); err != nil {
os.Exit(1)
Expand Down
2 changes: 1 addition & 1 deletion test/integration/cmd/cmd_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var _ = BeforeSuite(func() {
rootCmd.AddCommand(
cmd.CompletionCommand(),
cmd.VersionCommand("", "", "", ""),
cmd.GetCommand(),
cmd.ListCommand(),
cmd.CreateCommand())

Expect(rootCmd).NotTo(BeNil())
Expand Down

0 comments on commit e3ca4b2

Please # to comment.