-
Notifications
You must be signed in to change notification settings - Fork 13
/
tutorial.go
65 lines (58 loc) · 1.75 KB
/
tutorial.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
55
56
57
58
59
60
61
62
63
64
65
package cmdtree
import (
"github.com/ActiveState/cli/internal/analytics/constants"
"github.com/ActiveState/cli/internal/captain"
"github.com/ActiveState/cli/internal/errs"
"github.com/ActiveState/cli/internal/locale"
"github.com/ActiveState/cli/internal/primer"
"github.com/ActiveState/cli/internal/runners/tutorial"
)
func newTutorialCommand(prime *primer.Values) *captain.Command {
cmd := captain.NewCommand(
"tutorial",
locale.Tl("tutorial_title", "Running Tutorial"),
locale.Tl("tutorial_description", "Learn how to use the State Tool"),
prime,
nil,
nil,
func(ccmd *captain.Command, args []string) error {
prime.Output().Print(ccmd.UsageText())
return nil
},
)
cmd.SetHidden(true)
return cmd
}
func newTutorialProjectCommand(prime *primer.Values) *captain.Command {
runner := tutorial.New(prime)
params := tutorial.NewProjectParams{}
cmd := captain.NewCommand(
"new-project",
locale.Tl("tutorial_new_project", `Running "New Project" Tutorial`),
locale.Tl("tutorial_description", "Learn how to create new projects. (ie. virtual environments)"),
prime,
[]*captain.Flag{
{
Name: "skip-intro",
Description: locale.Tl("arg_tutorial_showintro", "Skip Introduction Text"),
Value: ¶ms.SkipIntro,
},
{
Name: "language",
Description: locale.Tl("arg_tutorial_language", "Language that this new project should use"),
Value: ¶ms.Language,
},
},
nil,
func(ccmd *captain.Command, args []string) error {
err := runner.RunNewProject(params)
if err != nil {
prime.Analytics().EventWithLabel(constants.CatTutorial, "error", errs.JoinMessage(err))
} else {
prime.Analytics().Event(constants.CatTutorial, "completed")
}
return err
},
)
return cmd
}