-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
637a31b
commit cd33e72
Showing
6 changed files
with
85 additions
and
3 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/starudream/sign-task/pkg/aliyun/cmd" | ||
) | ||
|
||
func init() { | ||
rootCmd.AddCommand(cmd.AliyunCmd) | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/starudream/go-lib/cobra/v2" | ||
"github.com/starudream/go-lib/core/v2/utils/fmtutil" | ||
"github.com/starudream/go-lib/tablew/v2" | ||
|
||
"github.com/starudream/sign-task/pkg/aliyun/config" | ||
) | ||
|
||
var ( | ||
accountCmd = cobra.NewCommand(func(c *cobra.Command) { | ||
c.Use = "account" | ||
c.Short = "Manage account" | ||
}) | ||
|
||
accountInitCmd = cobra.NewCommand(func(c *cobra.Command) { | ||
c.Use = "init" | ||
c.Short = "Init account information" | ||
c.Long = c.Short + "\n" + "Aliyun RAM: https://ram.console.aliyun.com/users" | ||
c.RunE = func(cmd *cobra.Command, args []string) error { | ||
id := fmtutil.Scan("please enter AccessKey ID: ") | ||
if id == "" { | ||
return nil | ||
} | ||
secret := fmtutil.Scan("please enter AccessKey Secret: ") | ||
if secret == "" { | ||
return nil | ||
} | ||
config.AddAccount(config.Account{Id: id, Secret: secret}) | ||
return config.Save() | ||
} | ||
}) | ||
|
||
accountListCmd = cobra.NewCommand(func(c *cobra.Command) { | ||
c.Use = "list" | ||
c.Aliases = []string{"ls"} | ||
c.Short = "List account" | ||
c.Run = func(cmd *cobra.Command, args []string) { | ||
fmt.Println(tablew.Structs(config.C().Accounts)) | ||
} | ||
}) | ||
) | ||
|
||
func init() { | ||
accountCmd.AddCommand(accountInitCmd) | ||
accountCmd.AddCommand(accountListCmd) | ||
|
||
AliyunCmd.AddCommand(accountCmd) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/starudream/go-lib/cobra/v2" | ||
) | ||
|
||
var AliyunCmd = cobra.NewCommand(func(c *cobra.Command) { | ||
c.Use = "aliyun" | ||
c.Short = "Manage aliyun" | ||
}) |
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