Compare commits

..

No commits in common. "b80fb1e879a78de0abebe32e6bd2ab5727972d79" and "c900b6f47864b1e1a44102d1992aead3ccae2732" have entirely different histories.

3 changed files with 25 additions and 9 deletions

View File

@ -656,8 +656,8 @@ Available recipes:
lint
```
Recipes in [submodules](#modules1190) can be listed with `just --list PATH`,
where `PATH` is a space- or `::`-separated module path:
Recipes in submodules can be listed with `just --list PATH`, where `PATH` is a
space- or `::`-separated module path:
```
$ cat justfile
@ -3145,7 +3145,7 @@ import? 'foo/bar.just'
Missing source files for optional imports do not produce an error.
### Modules<sup>1.19.0</sup>
### Modules <sup>1.19.0</sup>
A `justfile` can declare modules using `mod` statements. `mod` statements are
currently unstable, so you'll need to use the `--unstable` flag, or set the

View File

@ -131,7 +131,9 @@ mod arg {
COMMAND_COLOR_YELLOW,
];
pub(crate) const DUMP_FORMAT_JSON: &str = "json";
pub(crate) const DUMP_FORMAT_JUST: &str = "just";
pub(crate) const DUMP_FORMAT_VALUES: &[&str] = &[DUMP_FORMAT_JUST, DUMP_FORMAT_JSON];
}
impl Config {
@ -223,7 +225,7 @@ impl Config {
.long("dump-format")
.env("JUST_DUMP_FORMAT")
.action(ArgAction::Set)
.value_parser(clap::value_parser!(DumpFormat))
.value_parser(PossibleValuesParser::new(arg::DUMP_FORMAT_VALUES))
.default_value(arg::DUMP_FORMAT_JUST)
.value_name("FORMAT")
.help("Dump justfile as <FORMAT>"),
@ -565,6 +567,23 @@ impl Config {
}
}
fn dump_format_from_matches(matches: &ArgMatches) -> ConfigResult<DumpFormat> {
let value =
matches
.get_one::<String>(arg::DUMP_FORMAT)
.ok_or_else(|| ConfigError::Internal {
message: "`--dump-format` had no value".to_string(),
})?;
match value.as_str() {
arg::DUMP_FORMAT_JSON => Ok(DumpFormat::Json),
arg::DUMP_FORMAT_JUST => Ok(DumpFormat::Just),
_ => Err(ConfigError::Internal {
message: format!("Invalid argument `{value}` to --dump-format."),
}),
}
}
fn parse_module_path(values: ValuesRef<String>) -> ConfigResult<ModulePath> {
let path = values.clone().map(|s| (*s).as_str()).collect::<Vec<&str>>();
@ -734,10 +753,7 @@ impl Config {
.map(Into::into),
dotenv_path: matches.get_one::<PathBuf>(arg::DOTENV_PATH).map(Into::into),
dry_run: matches.get_flag(arg::DRY_RUN),
dump_format: matches
.get_one::<DumpFormat>(arg::DUMP_FORMAT)
.unwrap()
.clone(),
dump_format: Self::dump_format_from_matches(matches)?,
highlight: !matches.get_flag(arg::NO_HIGHLIGHT),
invocation_directory: env::current_dir().context(config_error::CurrentDirContext)?,
list_heading: matches

View File

@ -1,4 +1,4 @@
#[derive(Debug, PartialEq, Clone, clap::ValueEnum)]
#[derive(Debug, PartialEq)]
pub(crate) enum DumpFormat {
Json,
Just,