@@ -24,6 +24,8 @@ var profileSubCmd = make(map[string]func([]string) error)
2424
2525func init () {
2626 cmdMap ["profile" ] = & profileCmd {}
27+ cmdMap ["enable" ] = cmdMap ["profile" ]
28+ cmdMap ["disable" ] = cmdMap ["profile" ]
2729}
2830
2931func (cmd * profileCmd ) ProhibitRootExecution (args []string ) bool {
@@ -69,6 +71,14 @@ Command
6971 profile rename {old} {new}
7072 Rename profile {old} to {new}.
7173
74+ enable {repository} [{repository2} ...]
75+ This is shortcut of:
76+ volt profile add -current {repository} [{repository2} ...]
77+
78+ disable {repository} [{repository2} ...]
79+ This is shortcut of:
80+ volt profile rm -current {repository} [{repository2} ...]
81+
7282 profile add [-current | {name}] {repository} [{repository2} ...]
7383 Add one or more repositories to profile {name}.
7484
@@ -103,7 +113,7 @@ Quick example
103113
104114func (cmd * profileCmd ) Run (cmdctx * CmdContext ) * Error {
105115 // Parse args
106- args , err := cmd .parseArgs (cmdctx . Args )
116+ args , err := cmd .parseArgs (cmdctx )
107117 if err == ErrShowedHelp {
108118 return nil
109119 }
@@ -142,9 +152,18 @@ func (cmd *profileCmd) Run(cmdctx *CmdContext) *Error {
142152 return nil
143153}
144154
145- func (cmd * profileCmd ) parseArgs (args []string ) ([]string , error ) {
155+ func (cmd * profileCmd ) parseArgs (cmdctx * CmdContext ) ([]string , error ) {
156+ switch cmdctx .Cmd {
157+ case "enable" :
158+ cmdctx .Cmd = "profile"
159+ cmdctx .Args = append ([]string {"add" , "-current" }, cmdctx .Args ... )
160+ case "disable" :
161+ cmdctx .Cmd = "profile"
162+ cmdctx .Args = append ([]string {"rm" , "-current" }, cmdctx .Args ... )
163+ }
164+
146165 fs := cmd .FlagSet ()
147- fs .Parse (args )
166+ fs .Parse (cmdctx . Args )
148167 if cmd .helped {
149168 return nil , ErrShowedHelp
150169 }
0 commit comments