-
Notifications
You must be signed in to change notification settings - Fork 242
/
select.go
42 lines (37 loc) 路 960 Bytes
/
select.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
package context
import (
"github.com/smallstep/cli/flags"
"github.com/urfave/cli"
"go.step.sm/cli-utils/command"
"go.step.sm/cli-utils/errs"
"go.step.sm/cli-utils/step"
"go.step.sm/cli-utils/ui"
)
func selectCommand() cli.Command {
return cli.Command{
Name: "select",
Usage: "select the default certificate authority context",
UsageText: "**step context select**",
Description: `**step context select** command sets the default certificate authority context.
## EXAMPLES
Select the default certificate authority context:
'''
$ step context select alpha-one
'''`,
Action: command.ActionFunc(selectAction),
Flags: []cli.Flag{
flags.HiddenNoContext,
},
}
}
func selectAction(ctx *cli.Context) error {
if err := errs.NumberOfArguments(ctx, 1); err != nil {
return err
}
name := ctx.Args().Get(0)
if err := step.Contexts().SaveCurrent(name); err != nil {
return err
}
ui.PrintSelected("Context", name)
return nil
}