forked from sourcegraph/srclib
-
Notifications
You must be signed in to change notification settings - Fork 1
/
doall_cmd.go
63 lines (51 loc) · 1.2 KB
/
doall_cmd.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
package src
import (
"log"
"os"
"sourcegraph.com/sourcegraph/srclib/config"
)
func init() {
// TODO(sqs): "do-all" is a stupid name
c, err := CLI.AddCommand("do-all",
"fully process (config, plan, and execute)",
`Fully processes a tree: configures it, plans the execution, and executes all analysis steps.`,
&doAllCmd,
)
if err != nil {
log.Fatal(err)
}
SetRepoOptDefaults(c)
}
type DoAllCmd struct {
config.Options
ToolchainExecOpt `group:"execution"`
BuildCacheOpt `group:"build cache"`
Dir Directory `short:"C" long:"directory" description:"change to DIR before doing anything" value-name:"DIR"`
}
var doAllCmd DoAllCmd
func (c *DoAllCmd) Execute(args []string) error {
if c.Dir != "" {
if err := os.Chdir(string(c.Dir)); err != nil {
return err
}
}
// config
configCmd := &ConfigCmd{
Options: c.Options,
ToolchainExecOpt: c.ToolchainExecOpt,
BuildCacheOpt: c.BuildCacheOpt,
}
if err := configCmd.Execute(nil); err != nil {
return err
}
// make
makeCmd := &MakeCmd{
Options: c.Options,
ToolchainExecOpt: c.ToolchainExecOpt,
BuildCacheOpt: c.BuildCacheOpt,
}
if err := makeCmd.Execute(nil); err != nil {
return err
}
return nil
}