diff options
Diffstat (limited to 'helix-term/src')
-rw-r--r-- | helix-term/src/application.rs | 3 | ||||
-rw-r--r-- | helix-term/src/args.rs | 15 | ||||
-rw-r--r-- | helix-term/src/main.rs | 1 |
3 files changed, 19 insertions, 0 deletions
diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index 3e6da5bb..7c23ddfe 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -156,6 +156,9 @@ impl Application { let editor_view = Box::new(ui::EditorView::new(Keymaps::new(keys))); compositor.push(editor_view); + if let Some(path) = args.working_directory { + helix_loader::set_current_working_dir(path)? + } if args.load_tutor { let path = helix_loader::runtime_file(Path::new("tutor")); editor.open(&path, Action::VerticalSplit)?; 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) } diff --git a/helix-term/src/main.rs b/helix-term/src/main.rs index 542d18e6..009cbf7f 100644 --- a/helix-term/src/main.rs +++ b/helix-term/src/main.rs @@ -66,6 +66,7 @@ FLAGS: -V, --version Prints version information --vsplit Splits all given files vertically into different windows --hsplit Splits all given files horizontally into different windows + -w, --working-dir <path> Specify an initial working directory ", env!("CARGO_PKG_NAME"), VERSION_AND_GIT_HASH, |