diff options
Diffstat (limited to 'helix-term/src/args.rs')
-rw-r--r-- | helix-term/src/args.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/helix-term/src/args.rs b/helix-term/src/args.rs index dd787f1f..f782539c 100644 --- a/helix-term/src/args.rs +++ b/helix-term/src/args.rs @@ -17,6 +17,7 @@ pub struct Args { pub log_file: Option<PathBuf>, pub config_file: Option<PathBuf>, pub files: Vec<(PathBuf, Position)>, + pub working_directory: Option<PathBuf>, } impl Args { @@ -59,6 +60,20 @@ impl Args { Some(path) => args.log_file = Some(path.into()), None => anyhow::bail!("--log must specify a path to write"), }, + "-w" | "--working-dir" => match argv.next().as_deref() { + Some(path) => { + args.working_directory = if Path::new(path).is_dir() { + Some(PathBuf::from(path)) + } else { + anyhow::bail!( + "--working-dir specified does not exist or is not a directory" + ) + } + } + None => { + anyhow::bail!("--working-dir must specify an initial working directory") + } + }, arg if arg.starts_with("--") => { anyhow::bail!("unexpected double dash argument: {}", arg) } |