Skip to content
This repository was archived by the owner on May 9, 2022. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ use std::path::{Path, PathBuf};

const DEVLOG_REPO_ENV_VAR: &'static str = "DEVLOG_REPO";
const DEFAULT_HOME_DIR: &'static str = "devlogs";
const EDITOR_ENV_VAR: &'static str = "DEVLOG_EDITOR";
const DEVLOG_EDITOR_ENV_VAR: &'static str = "DEVLOG_EDITOR";
const EDITOR_ENV_VAR: &'static str = "EDITOR";
const DEFAULT_EDITOR: &'static str = "nano";

pub struct Config {
Expand All @@ -32,7 +33,10 @@ impl Config {
.unwrap_or_else(default_repo_dir);
let repo_dir = PathBuf::from(repo_dir_str);

let editor_prog = env::var(EDITOR_ENV_VAR).unwrap_or(DEFAULT_EDITOR.to_string());
// $DEVLOG_EDITOR > $EDITOR > nano
let editor_prog = env::var(DEVLOG_EDITOR_ENV_VAR)
.or_else(|_| env::var(EDITOR_ENV_VAR))
.unwrap_or_else(|_| DEFAULT_EDITOR.to_string());

Config {
repo_dir,
Expand Down