feat(installer): set default editor

Attempt to set and locate a default editor when running the installer.
This commit is contained in:
Christopher Allen Lane
2022-08-08 20:14:27 -04:00
parent 0c47f44ff9
commit 6421953183
4 changed files with 24 additions and 6 deletions

View File

@ -20,11 +20,18 @@ func Run(configs string, confpath string) error {
community := filepath.Join(confdir, "cheatsheets", "community")
personal := filepath.Join(confdir, "cheatsheets", "personal")
// template the above paths into the default configs
// set default cheatpaths
configs = strings.Replace(configs, "COMMUNITY_PATH", community, -1)
configs = strings.Replace(configs, "PERSONAL_PATH", personal, -1)
// locate and set a default pager
configs = strings.Replace(configs, "PAGER_PATH", config.Pager(), -1)
// locate and set a default editor
if editor, err := config.Editor(); err == nil {
configs = strings.Replace(configs, "EDITOR_PATH", editor, -1)
}
// prompt the user to download the community cheatsheets
yes, err := Prompt(
"Would you like to download the community cheatsheets? [Y/n]",