e948f11784
When `--init` is passed on the command line, search upward for the project root, identified by the presence of a VCS directory like `.git`, falling back to the current directory, and create a default justfile in that directory.
59 lines
1.6 KiB
Rust
59 lines
1.6 KiB
Rust
use crate::common::*;
|
|
|
|
#[derive(Debug, Snafu)]
|
|
#[snafu(visibility(pub(crate)))]
|
|
pub(crate) enum ConfigError {
|
|
#[snafu(display(
|
|
"Internal config error, this may indicate a bug in just: {} \
|
|
consider filing an issue: https://github.com/casey/just/issues/new",
|
|
message
|
|
))]
|
|
Internal { message: String },
|
|
#[snafu(display("Failed to get current directory: {}", source))]
|
|
CurrentDir { source: io::Error },
|
|
#[snafu(display(
|
|
"Path-prefixed recipes may not be used with `--working-directory` or `--justfile`."
|
|
))]
|
|
SearchDirConflict,
|
|
#[snafu(display(
|
|
"`{}` used with unexpected {}: {}",
|
|
subcommand,
|
|
Count("argument", arguments.len()),
|
|
List::and_ticked(arguments)
|
|
))]
|
|
SubcommandArguments {
|
|
subcommand: String,
|
|
arguments: Vec<String>,
|
|
},
|
|
#[snafu(display(
|
|
"`{}` used with unexpected overrides: {}; and arguments: {}",
|
|
subcommand,
|
|
List::and_ticked(overrides.iter().map(|(key, value)| format!("{}={}", key, value))),
|
|
List::and_ticked(arguments)))
|
|
]
|
|
SubcommandOverridesAndArguments {
|
|
subcommand: String,
|
|
overrides: BTreeMap<String, String>,
|
|
arguments: Vec<String>,
|
|
},
|
|
#[snafu(display(
|
|
"`{}` used with unexpected overrides: {}",
|
|
subcommand,
|
|
List::and_ticked(overrides.iter().map(|(key, value)| format!("{}={}", key, value))),
|
|
))]
|
|
SubcommandOverrides {
|
|
subcommand: String,
|
|
overrides: BTreeMap<String, String>,
|
|
},
|
|
}
|
|
|
|
impl ConfigError {
|
|
pub(crate) fn internal(message: impl Into<String>) -> ConfigError {
|
|
ConfigError::Internal {
|
|
message: message.into(),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Error for ConfigError {}
|