68 lines
1.4 KiB
Go
68 lines
1.4 KiB
Go
/*
|
|
* Copyright 2026 Oleg Borodin <onborodin@gmail.com>
|
|
*/
|
|
package account
|
|
|
|
import (
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
type Util struct {
|
|
rootCmd *cobra.Command
|
|
createAccountParams createAccountParams
|
|
listAccountsParams listAccountsParams
|
|
updateAccountParams updateAccountParams
|
|
deleteAccountParams deleteAccountParams
|
|
}
|
|
|
|
func NewUtil() *Util {
|
|
return &Util{}
|
|
}
|
|
|
|
func (util *Util) GetRooCmd() *cobra.Command {
|
|
return util.rootCmd
|
|
}
|
|
|
|
func (util *Util) BuildCmds() *cobra.Command {
|
|
rootCmd := &cobra.Command{
|
|
Use: "account",
|
|
Short: "\nAccount operations",
|
|
SilenceUsage: true,
|
|
}
|
|
rootCmd.CompletionOptions.DisableDefaultCmd = true
|
|
|
|
var createAccountCmd = &cobra.Command{
|
|
Use: "create name password ",
|
|
Short: "Create account",
|
|
Args: cobra.ExactArgs(2),
|
|
Run: util.CreateAccount,
|
|
}
|
|
rootCmd.AddCommand(createAccountCmd)
|
|
|
|
var listAccountsCmd = &cobra.Command{
|
|
Use: "list",
|
|
Short: "List accounts",
|
|
Run: util.ListAccounts,
|
|
}
|
|
rootCmd.AddCommand(listAccountsCmd)
|
|
|
|
var updateAccountsCmd = &cobra.Command{
|
|
Use: "update name|id",
|
|
Short: "Update account",
|
|
Args: cobra.ExactArgs(1),
|
|
Run: util.UpdateAccount,
|
|
}
|
|
rootCmd.AddCommand(updateAccountsCmd)
|
|
|
|
var deleteAccountCmd = &cobra.Command{
|
|
Use: "delete name|id",
|
|
Short: "Delete account",
|
|
Args: cobra.ExactArgs(1),
|
|
Run: util.DeleteAccount,
|
|
}
|
|
rootCmd.AddCommand(deleteAccountCmd)
|
|
|
|
util.rootCmd = rootCmd
|
|
return util.rootCmd
|
|
}
|