-
Notifications
You must be signed in to change notification settings - Fork 13
/
branch.go
54 lines (47 loc) · 1.56 KB
/
branch.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package cmdtree
import (
"github.com/ActiveState/cli/internal/captain"
"github.com/ActiveState/cli/internal/locale"
"github.com/ActiveState/cli/internal/primer"
"github.com/ActiveState/cli/internal/runners/branch"
"github.com/ActiveState/cli/internal/runners/swtch"
)
func newBranchCommand(prime *primer.Values) *captain.Command {
runner := branch.NewList(prime)
return captain.NewCommand(
"branch",
locale.Tl("branch_title", "Listing branches"),
locale.Tl("branch_description", "Manage your project's branches"),
prime,
[]*captain.Flag{},
[]*captain.Argument{},
func(_ *captain.Command, _ []string) error {
return runner.Run()
}).SetGroup(PlatformGroup).SetSupportsStructuredOutput().SetUnstable(true)
}
func newBranchSwitchCommand(prime *primer.Values) *captain.Command {
runner := swtch.New(prime)
params := swtch.SwitchParams{}
cmd := captain.NewCommand(
"switch",
locale.Tl("switch_title", "Switching branches"),
locale.Tl("switch_description", "Switch to the given branch name"),
prime,
[]*captain.Flag{},
[]*captain.Argument{
{
Name: locale.Tl("switch_arg_identifier", "identifier"),
Description: locale.Tl("switch_arg_identifier_description", "The commit or branch to switch to"),
Value: ¶ms.Identifier,
Required: true,
},
},
func(_ *captain.Command, _ []string) error {
return runner.Run(params)
})
cmd.SetSupportsStructuredOutput()
// We set this command to hidden for backwards compatibility as we cannot
// alias `state switch` to `state branch switch`
cmd.SetHidden(true)
return cmd
}