/
root_dir.go
42 lines (34 loc) · 931 Bytes
/
root_dir.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 cli
import (
"fmt"
"github.com/khulnasoftproj/khulnasoft/v2/pkg/config"
"github.com/suzuki-shunsuke/go-osenv/osenv"
"github.com/urfave/cli/v2"
)
func (runner *Runner) newRootDirCommand() *cli.Command {
return &cli.Command{
Name: "root-dir",
Usage: "Output the khulnasoft root directory (KHULNASOFT_ROOT_DIR)",
Description: `Output the khulnasoft root directory (KHULNASOFT_ROOT_DIR)
e.g.
$ khulnasoft root-dir
/home/foo/.local/share/khulnasoftproj-khulnasoft
$ export "PATH=$(khulnasoft root-dir)/bin:PATH"
`,
Action: runner.rootDirAction,
}
}
func (runner *Runner) rootDirAction(c *cli.Context) error {
tracer, err := startTrace(c.String("trace"))
if err != nil {
return err
}
defer tracer.Stop()
cpuProfiler, err := startCPUProfile(c.String("cpu-profile"))
if err != nil {
return err
}
defer cpuProfiler.Stop()
fmt.Fprintln(runner.Stdout, config.GetRootDir(osenv.New()))
return nil
}