func ensureLingoHome() { // create lingo home if it doesn't exist lHome := util.MustLingoHome() if _, err := os.Stat(lHome); os.IsNotExist(err) { err := os.MkdirAll(lHome, 0775) if err != nil { panic(err) } } tenetsHome := filepath.Join(lHome, "tenets") if _, err := os.Stat(tenetsHome); os.IsNotExist(err) { err := os.MkdirAll(tenetsHome, 0775) if err != nil { panic(err) } } logsHome := filepath.Join(lHome, "logs") if _, err := os.Stat(logsHome); os.IsNotExist(err) { err := os.MkdirAll(logsHome, 0775) if err != nil { panic(err) } } scriptsHome := filepath.Join(lHome, "scripts") if _, err := os.Stat(scriptsHome); os.IsNotExist(err) { err := os.MkdirAll(scriptsHome, 0775) if err != nil { fmt.Printf("WARNING: could not create scripts directory: %v \n", err) } } }
func listAction(c *cli.Context) { // TODO(waigani) DEMOWARE if c.Bool("installed") { var stdout bytes.Buffer cmd := exec.Command("tree", filepath.Join(util.MustLingoHome(), "tenets")) cmd.Stdout = &stdout // cmd.Stderr = &stderr cmd.Run() fmt.Print(string(stdout.Bytes())) return } for _, t := range listTenets(c) { fmt.Printf("%s (%s)\n", t.Name, t.Driver) } }
func (f *flagName) String() string { return f.Long + ", " + f.Short } var GlobalOptions = []cli.Flag{ cli.StringFlag{ Name: RepoPathFlg.String(), Value: ".", Usage: "the directory to operate in, defaults to current directory", EnvVar: "LINGO_REPO_PATH", }, cli.StringFlag{ Name: LingoHomeFlg.String(), Value: util.MustLingoHome(), Usage: "a directory of files needed for Lingo to operate e.g. logs and binary tenets are stored here", EnvVar: "LINGO_HOME", }, // TODO(waigani) implement or drop cli.StringFlag{ Name: TenetCfgFlg.String(), Value: DefaultTenetCfgPath, Usage: "path to a .lingo to use. Defaults to " + DefaultTenetCfgPath + " in current directory", EnvVar: "LINGO_TENET_CONFIG_NAME", }, // cli.StringFlag{ // Name: outputTemplateFlg.String(), // Value: "", // Usage: "a template for the output format",