@@ -17,6 +17,7 @@ pub struct Args {
1717 pub log_file: Option<PathBuf>,
1818 pub config_file: Option<PathBuf>,
1919 pub files: Vec<(PathBuf, Position)>,
20+ pub working_directory: Option<PathBuf>,
2021}
2122
2223impl Args {
@@ -59,6 +60,20 @@ impl Args {
5960 Some(path) => args.log_file = Some(path.into()),
6061 None => anyhow::bail!("--log must specify a path to write"),
6162 },
63+ "-w" | "--working-dir" => match argv.next().as_deref() {
64+ Some(path) => {
65+ args.working_directory = if Path::new(path).is_dir() {
66+ Some(PathBuf::from(path))
67+ } else {
68+ anyhow::bail!(
69+ "--working-dir specified does not exist or is not a directory"
70+ )
71+ }
72+ }
73+ None => {
74+ anyhow::bail!("--working-dir must specify an initial working directory")
75+ }
76+ },
6277 arg if arg.starts_with("--") => {
6378 anyhow::bail!("unexpected double dash argument: {}", arg)
6479 }