Beispiel #1
0
func sourceAutoComplete(c *cli.Context) {
	uHome, err := util.UserHome()
	if err != nil {
		oserrf(err.Error())
		return
	}
	autoCompScriptPath := filepath.Join(uHome, ".lingo_home/scripts/bash_autocomplete.sh")
	err = ioutil.WriteFile(autoCompScriptPath, []byte(bash_autocomplete), 0775)
	if err != nil {
		fmt.Println("WARNING: could not write script:")
		oserrf(err.Error())
		return
	}

	// TODO(waigani) this just works for linux
	bashrcPath := filepath.Join(uHome, ".bashrc")
	f, err := os.OpenFile(bashrcPath, os.O_APPEND|os.O_WRONLY, 0600)
	if err != nil {
		oserrf(err.Error())
		return
	}
	defer f.Close()

	if _, err = f.WriteString("\nPROG=lingo source " + autoCompScriptPath); err != nil {
		oserrf(err.Error())
		return
	}

	fmt.Print(`
Success! Please run the following commands to complete the setup:
. ~/.bashrc
lingo --generate-bash-completion
`[1:])
}
Beispiel #2
0
// TODO(waigani) remove when dev is published
func lrRoot() (string, error) {
	h, err := util.UserHome()
	if err != nil {
		return "", errors.Trace(err)
	}

	return filepath.Join(h, "go", "src", "github.com", "lingo-reviews"), nil
}