1use super::*;
2
3#[derive(Debug, Snafu)]
4#[snafu(visibility(pub), context(suffix(Context)))]
5pub enum ConfigError {
6 #[snafu(display("Failed to get current directory: {}", source))]
7 CurrentDir { source: io::Error },
8 #[snafu(display(
9 "Internal config error, this may indicate a bug in just: {message} \
10 consider filing an issue: https://github.com/casey/just/issues/new",
11 ))]
12 Internal { message: String },
13 #[snafu(display("Invalid module path `{}`", path.join(" ")))]
14 ModulePath { path: Vec<String> },
15 #[snafu(display(
16 "Path-prefixed recipes may not be used with `--working-directory` or `--justfile`."
17 ))]
18 SearchDirConflict,
19 #[snafu(display(
20 "`--{}` used with unexpected {}: {}",
21 subcommand.to_lowercase(),
22 Count("argument", arguments.len()),
23 List::and_ticked(arguments)
24 ))]
25 SubcommandArguments {
26 subcommand: &'static str,
27 arguments: Vec<String>,
28 },
29 #[snafu(display(
30 "`--{}` used with unexpected overrides: {}",
31 subcommand.to_lowercase(),
32 List::and_ticked(overrides.iter().map(|(key, value)| format!("{key}={value}"))),
33 ))]
34 SubcommandOverrides {
35 subcommand: &'static str,
36 overrides: BTreeMap<String, String>,
37 },
38 #[snafu(display(
39 "`--{}` used with unexpected overrides: {}; and arguments: {}",
40 subcommand.to_lowercase(),
41 List::and_ticked(overrides.iter().map(|(key, value)| format!("{key}={value}"))),
42 List::and_ticked(arguments)))
43 ]
44 SubcommandOverridesAndArguments {
45 subcommand: &'static str,
46 overrides: BTreeMap<String, String>,
47 arguments: Vec<String>,
48 },
49}
50
51impl ConfigError {
52 pub fn internal(message: impl Into<String>) -> Self {
53 Self::Internal {
54 message: message.into(),
55 }
56 }
57}