Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cli --working-path option added to helix-term #8162

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions helix-term/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ impl Application {
let picker = ui::file_picker(".".into(), &config.load().editor);
compositor.push(Box::new(overlaid(picker)));
} else {
match args.working_path {
Some(path) => helix_loader::set_current_working_dir(path.clone())?,
None => log::warn!("invalid working path given"),
}
let nr_of_files = args.files.len();
for (i, (file, pos)) in args.files.into_iter().enumerate() {
if file.is_dir() {
Expand Down
5 changes: 5 additions & 0 deletions helix-term/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub struct Args {
pub log_file: Option<PathBuf>,
pub config_file: Option<PathBuf>,
pub files: Vec<(PathBuf, Position)>,
pub working_path: Option<PathBuf>,
}

impl Args {
Expand Down Expand Up @@ -59,6 +60,10 @@ impl Args {
Some(path) => args.log_file = Some(path.into()),
None => anyhow::bail!("--log must specify a path to write"),
},
"-w" | "--working-path" => match argv.next().as_deref() {
Some(path) => args.working_path = if Path::new(path).exists() {Some(PathBuf::from(path))} else {None},
None => anyhow::bail!("--working-path must specify an initial working directory"),
},
arg if arg.starts_with("--") => {
anyhow::bail!("unexpected double dash argument: {}", arg)
}
Expand Down
1 change: 1 addition & 0 deletions helix-term/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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-path <path> Specify an initial working directory
",
env!("CARGO_PKG_NAME"),
VERSION_AND_GIT_HASH,
Expand Down