Add --project-origin override

This commit is contained in:
Félix Saparelli 2022-01-26 04:19:07 +13:00 committed by Félix Saparelli
parent 4a6d4350c5
commit 84aac2243c
4 changed files with 60 additions and 46 deletions

View File

@ -153,7 +153,12 @@ pub fn get_args(tagged_filterer: bool) -> Result<ArgMatches<'static>> {
.help_heading(Some(OPTSET_OUTPUT))
.help("Send a desktop notification when the command ends")
.short("N")
.long("notify"));
.long("notify"))
.arg(Arg::with_name("project-origin")
.help_heading(Some(OPTSET_FILTERING))
.help("Override the project origin: the directory from which ignore files are detected")
.value_name("path")
.long("project-origin"));
let app = if tagged_filterer {
app.arg(

View File

@ -20,6 +20,10 @@ pub async fn dirs(args: &ArgMatches<'static>) -> Result<(PathBuf, PathBuf)> {
.into_diagnostic()?;
debug!(?curdir, "current directory");
let project_origin = if let Some(origin) = args.value_of("project-origin") {
debug!(?origin, "project origin override");
canonicalize(origin).into_diagnostic()?
} else {
let homedir = dirs::home_dir()
.map(canonicalize)
.transpose()
@ -65,11 +69,12 @@ pub async fn dirs(args: &ArgMatches<'static>) -> Result<(PathBuf, PathBuf)> {
debug!(?origins, "resolved all project origins");
// This canonicalize is probably redundant
let project_origin = canonicalize(
canonicalize(
common_prefix(&origins)
.ok_or_else(|| miette!("no common prefix, but this should never fail"))?,
)
.into_diagnostic()?;
.into_diagnostic()?
};
debug!(?project_origin, "resolved common/project origin");
let workdir = curdir;

View File

@ -39,6 +39,8 @@ OPTIONS:
[possible values: do-nothing, queue, restart, signal]
-w, --watch <path>... Watch a specific file or directory
--force-poll <interval> Force polling mode (interval in milliseconds)
--project-origin <path> Override the project origin: the directory from which ignore files are
detected
--shell <shell> Use a different shell, or `none`. Defaults to `sh` (until 2.0, where that
will change to `$SHELL`). E.g. --shell=bash
-s, --signal <signal> Specify the signal to send when using --on-busy-update=signal

View File

@ -38,6 +38,8 @@ OPTIONS:
[possible values: do-nothing, queue, restart, signal]
-w, --watch <path>... Watch a specific file or directory
--force-poll <interval> Force polling mode (interval in milliseconds)
--project-origin <path> Override the project origin: the directory from which ignore files are
detected
--shell <shell> Use a different shell, or `none`. Try --shell=powershell, which will become
the default in 2.0.
-s, --signal <signal> Specify the signal to send when using --on-busy-update=signal