Use CAPITALIZED option names (#176)
Since this seems to be the convention.
This commit is contained in:
parent
c9ce4601b9
commit
f38f984f12
93
src/app.rs
93
src/app.rs
@ -91,86 +91,87 @@ pub fn app() {
|
|||||||
.author("Casey Rodarmor <casey@rodarmor.com>")
|
.author("Casey Rodarmor <casey@rodarmor.com>")
|
||||||
.about("Just a command runner - https://github.com/casey/just")
|
.about("Just a command runner - https://github.com/casey/just")
|
||||||
.setting(AppSettings::ColoredHelp)
|
.setting(AppSettings::ColoredHelp)
|
||||||
.arg(Arg::with_name("arguments")
|
.arg(Arg::with_name("ARGUMENTS")
|
||||||
.multiple(true)
|
.multiple(true)
|
||||||
.help("The recipe(s) to run, defaults to the first recipe in the justfile"))
|
.help("The recipe(s) to run, defaults to the first recipe in the justfile"))
|
||||||
.arg(Arg::with_name("color")
|
.arg(Arg::with_name("COLOR")
|
||||||
.long("color")
|
.long("color")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.possible_values(&["auto", "always", "never"])
|
.possible_values(&["auto", "always", "never"])
|
||||||
.default_value("auto")
|
.default_value("auto")
|
||||||
.help("Prints colorful output"))
|
.help("Prints colorful output"))
|
||||||
.arg(Arg::with_name("dry-run")
|
.arg(Arg::with_name("DRY-RUN")
|
||||||
.long("dry-run")
|
.long("dry-run")
|
||||||
.help("Prints what just would do without doing it")
|
.help("Prints what just would do without doing it")
|
||||||
.conflicts_with("quiet"))
|
.conflicts_with("quiet"))
|
||||||
.arg(Arg::with_name("dump")
|
.arg(Arg::with_name("DUMP")
|
||||||
.long("dump")
|
.long("dump")
|
||||||
.help("Prints entire justfile"))
|
.help("Prints entire justfile"))
|
||||||
.arg(Arg::with_name("edit")
|
.arg(Arg::with_name("EDIT")
|
||||||
.short("e")
|
.short("e")
|
||||||
.long("edit")
|
.long("edit")
|
||||||
.help("Opens justfile with $EDITOR"))
|
.help("Opens justfile with $EDITOR"))
|
||||||
.arg(Arg::with_name("evaluate")
|
.arg(Arg::with_name("EVALUATE")
|
||||||
.long("evaluate")
|
.long("evaluate")
|
||||||
.help("Prints evaluated variables"))
|
.help("Prints evaluated variables"))
|
||||||
.arg(Arg::with_name("justfile")
|
.arg(Arg::with_name("JUSTFILE")
|
||||||
.long("justfile")
|
.long("justfile")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.help("Uses <justfile> as justfile. --working-directory must also be set")
|
.help("Uses <JUSTFILE> as justfile. --working-directory must also be set")
|
||||||
.requires("working-directory"))
|
.requires("WORKING-DIRECTORY"))
|
||||||
.arg(Arg::with_name("list")
|
.arg(Arg::with_name("LIST")
|
||||||
.short("l")
|
.short("l")
|
||||||
.long("list")
|
.long("list")
|
||||||
.help("Lists available recipes and their arguments"))
|
.help("Lists available recipes and their arguments"))
|
||||||
.arg(Arg::with_name("quiet")
|
.arg(Arg::with_name("QUIET")
|
||||||
.short("q")
|
.short("q")
|
||||||
.long("quiet")
|
.long("quiet")
|
||||||
.help("Suppresses all output")
|
.help("Suppresses all output")
|
||||||
.conflicts_with("dry-run"))
|
.conflicts_with("DRY-RUN"))
|
||||||
.arg(Arg::with_name("set")
|
.arg(Arg::with_name("SET")
|
||||||
.long("set")
|
.long("set")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.number_of_values(2)
|
.number_of_values(2)
|
||||||
.value_names(&["variable", "value"])
|
.value_names(&["VARIABLE", "VALUE"])
|
||||||
.multiple(true)
|
.multiple(true)
|
||||||
.help("Sets <variable> to <value>"))
|
.help("Sets <VARIABLE> to <VALUE>"))
|
||||||
.arg(Arg::with_name("shell")
|
.arg(Arg::with_name("SHELL")
|
||||||
.long("shell")
|
.long("shell")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.default_value(DEFAULT_SHELL)
|
.default_value(DEFAULT_SHELL)
|
||||||
.help("Invoke <shell> to run recipes"))
|
.help("Invoke <SHELL> to run recipes"))
|
||||||
.arg(Arg::with_name("show")
|
.arg(Arg::with_name("SHOW")
|
||||||
.short("s")
|
.short("s")
|
||||||
.long("show")
|
.long("show")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.value_name("recipe")
|
.value_name("RECIPE")
|
||||||
.help("Shows information about <recipe>"))
|
.help("Shows information about <RECIPE>"))
|
||||||
.arg(Arg::with_name("summary")
|
.arg(Arg::with_name("SUMMARY")
|
||||||
.long("summary")
|
.long("summary")
|
||||||
.help("Lists names of available recipes"))
|
.help("Lists names of available recipes"))
|
||||||
.arg(Arg::with_name("verbose")
|
.arg(Arg::with_name("VERBOSE")
|
||||||
.short("v") .long("verbose")
|
.short("v")
|
||||||
|
.long("verbose")
|
||||||
.help("Use verbose output"))
|
.help("Use verbose output"))
|
||||||
.arg(Arg::with_name("working-directory")
|
.arg(Arg::with_name("WORKING-DIRECTORY")
|
||||||
.long("working-directory")
|
.long("working-directory")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.help("Uses <working-directory> as working directory. --justfile must also be set")
|
.help("Uses <WORKING-DIRECTORY> as working directory. --justfile must also be set")
|
||||||
.requires("justfile"))
|
.requires("JUSTFILE"))
|
||||||
.group(ArgGroup::with_name("early-exit")
|
.group(ArgGroup::with_name("EARLY-EXIT")
|
||||||
.args(&["dump", "edit", "list", "show", "summary", "arguments", "evaluate"]))
|
.args(&["DUMP", "EDIT", "LIST", "SHOW", "SUMMARY", "ARGUMENTS", "EVALUATE"]))
|
||||||
.get_matches();
|
.get_matches();
|
||||||
|
|
||||||
let use_color_argument = matches.value_of("color").expect("--color had no value");
|
let use_color_argument = matches.value_of("COLOR").expect("--color had no value");
|
||||||
let use_color = match UseColor::from_argument(use_color_argument) {
|
let use_color = match UseColor::from_argument(use_color_argument) {
|
||||||
Some(use_color) => use_color,
|
Some(use_color) => use_color,
|
||||||
None => die!("Invalid argument to --color. This is a bug in just."),
|
None => die!("Invalid argument to --color. This is a bug in just."),
|
||||||
};
|
};
|
||||||
|
|
||||||
let set_count = matches.occurrences_of("set");
|
let set_count = matches.occurrences_of("SET");
|
||||||
let mut overrides = BTreeMap::new();
|
let mut overrides = BTreeMap::new();
|
||||||
if set_count > 0 {
|
if set_count > 0 {
|
||||||
let mut values = matches.values_of("set").unwrap();
|
let mut values = matches.values_of("SET").unwrap();
|
||||||
for _ in 0..set_count {
|
for _ in 0..set_count {
|
||||||
overrides.insert(values.next().unwrap(), values.next().unwrap());
|
overrides.insert(values.next().unwrap(), values.next().unwrap());
|
||||||
}
|
}
|
||||||
@ -178,7 +179,7 @@ pub fn app() {
|
|||||||
|
|
||||||
let override_re = regex::Regex::new("^([^=]+)=(.*)$").unwrap();
|
let override_re = regex::Regex::new("^([^=]+)=(.*)$").unwrap();
|
||||||
|
|
||||||
let raw_arguments = matches.values_of("arguments").map(|values| values.collect::<Vec<_>>())
|
let raw_arguments = matches.values_of("ARGUMENTS").map(|values| values.collect::<Vec<_>>())
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
|
||||||
for argument in raw_arguments.iter().take_while(|arg| override_re.is_match(arg)) {
|
for argument in raw_arguments.iter().take_while(|arg| override_re.is_match(arg)) {
|
||||||
@ -191,7 +192,7 @@ pub fn app() {
|
|||||||
.flat_map(|(i, argument)| {
|
.flat_map(|(i, argument)| {
|
||||||
if i == 0 {
|
if i == 0 {
|
||||||
if let Some(i) = argument.rfind('/') {
|
if let Some(i) = argument.rfind('/') {
|
||||||
if matches.is_present("working-directory") {
|
if matches.is_present("WORKING-DIRECTORY") {
|
||||||
die!("--working-directory and a path prefixed recipe may not be used together.");
|
die!("--working-directory and a path prefixed recipe may not be used together.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,12 +214,12 @@ pub fn app() {
|
|||||||
})
|
})
|
||||||
.collect::<Vec<&str>>();
|
.collect::<Vec<&str>>();
|
||||||
|
|
||||||
let justfile_option = matches.value_of("justfile");
|
let justfile_option = matches.value_of("JUSTFILE");
|
||||||
let working_directory_option = matches.value_of("working-directory");
|
let working_directory_option = matches.value_of("WORKING-DIRECTORY");
|
||||||
|
|
||||||
let text;
|
let text;
|
||||||
if let (Some(file), Some(directory)) = (justfile_option, working_directory_option) {
|
if let (Some(file), Some(directory)) = (justfile_option, working_directory_option) {
|
||||||
if matches.is_present("edit") {
|
if matches.is_present("EDIT") {
|
||||||
edit(file);
|
edit(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,7 +258,7 @@ pub fn app() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if matches.is_present("edit") {
|
if matches.is_present("EDIT") {
|
||||||
edit(name);
|
edit(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,7 +276,7 @@ pub fn app() {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
if matches.is_present("summary") {
|
if matches.is_present("SUMMARY") {
|
||||||
if justfile.count() == 0 {
|
if justfile.count() == 0 {
|
||||||
warn!("Justfile contains no recipes.");
|
warn!("Justfile contains no recipes.");
|
||||||
} else {
|
} else {
|
||||||
@ -284,12 +285,12 @@ pub fn app() {
|
|||||||
process::exit(0);
|
process::exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if matches.is_present("dump") {
|
if matches.is_present("DUMP") {
|
||||||
println!("{}", justfile);
|
println!("{}", justfile);
|
||||||
process::exit(0);
|
process::exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if matches.is_present("list") {
|
if matches.is_present("LIST") {
|
||||||
let blue = use_color.blue(atty::Stream::Stdout);
|
let blue = use_color.blue(atty::Stream::Stdout);
|
||||||
println!("Available recipes:");
|
println!("Available recipes:");
|
||||||
for (name, recipe) in &justfile.recipes {
|
for (name, recipe) in &justfile.recipes {
|
||||||
@ -309,7 +310,7 @@ pub fn app() {
|
|||||||
process::exit(0);
|
process::exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(name) = matches.value_of("show") {
|
if let Some(name) = matches.value_of("SHOW") {
|
||||||
match justfile.recipes.get(name) {
|
match justfile.recipes.get(name) {
|
||||||
Some(recipe) => {
|
Some(recipe) => {
|
||||||
println!("{}", recipe);
|
println!("{}", recipe);
|
||||||
@ -334,13 +335,13 @@ pub fn app() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let options = RunOptions {
|
let options = RunOptions {
|
||||||
dry_run: matches.is_present("dry-run"),
|
dry_run: matches.is_present("DRY-RUN"),
|
||||||
evaluate: matches.is_present("evaluate"),
|
evaluate: matches.is_present("EVALUATE"),
|
||||||
overrides: overrides,
|
overrides: overrides,
|
||||||
quiet: matches.is_present("quiet"),
|
quiet: matches.is_present("QUIET"),
|
||||||
shell: matches.value_of("shell"),
|
shell: matches.value_of("SHELL"),
|
||||||
use_color: use_color,
|
use_color: use_color,
|
||||||
verbose: matches.is_present("verbose"),
|
verbose: matches.is_present("VERBOSE"),
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Err(run_error) = justfile.run(&arguments, &options) {
|
if let Err(run_error) = justfile.run(&arguments, &options) {
|
||||||
|
@ -938,7 +938,7 @@ fn quiet_flag_or_dry_run_flag() {
|
|||||||
"error: The argument '--dry-run' cannot be used with '--quiet'
|
"error: The argument '--dry-run' cannot be used with '--quiet'
|
||||||
|
|
||||||
USAGE:
|
USAGE:
|
||||||
just --color <color> --quiet --shell <shell>
|
just --color <COLOR> --quiet --shell <SHELL>
|
||||||
|
|
||||||
For more information try --help\n",
|
For more information try --help\n",
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user