mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 13:59:08 +00:00
Remove --
requirement for roc [FILE]
to allow better messaging
This commit is contained in:
parent
0f1b85757a
commit
7435a65d0f
1 changed files with 21 additions and 8 deletions
|
@ -140,14 +140,14 @@ pub fn build_app() -> Command {
|
|||
.help("Arguments to pass into the app being run\ne.g. `roc run -- arg1 arg2`")
|
||||
.value_parser(value_parser!(OsString))
|
||||
.num_args(0..)
|
||||
.allow_hyphen_values(true)
|
||||
.last(true);
|
||||
.allow_hyphen_values(true);
|
||||
|
||||
let build_target_values_parser =
|
||||
PossibleValuesParser::new(Target::iter().map(Into::<&'static str>::into));
|
||||
let app = Command::new("roc")
|
||||
.version(concatcp!(VERSION, "\n"))
|
||||
.about("Run the given .roc file, if there are no compilation errors.\nYou can use one of the SUBCOMMANDS below to do something else!")
|
||||
.args_conflicts_with_subcommands(true)
|
||||
.subcommand(Command::new(CMD_BUILD)
|
||||
.about("Build a binary from the given .roc file, but don't run it")
|
||||
.arg(flag_optimize.clone())
|
||||
|
@ -214,7 +214,7 @@ pub fn build_app() -> Command {
|
|||
.required(false)
|
||||
.default_value(DEFAULT_ROC_FILENAME)
|
||||
)
|
||||
.arg(args_for_app.clone())
|
||||
.arg(args_for_app.clone().last(true))
|
||||
)
|
||||
.subcommand(Command::new(CMD_REPL)
|
||||
.about("Launch the interactive Read Eval Print Loop (REPL)")
|
||||
|
@ -230,7 +230,7 @@ pub fn build_app() -> Command {
|
|||
.arg(flag_linker.clone())
|
||||
.arg(flag_prebuilt.clone())
|
||||
.arg(roc_file_to_run.clone())
|
||||
.arg(args_for_app.clone())
|
||||
.arg(args_for_app.clone().last(true))
|
||||
)
|
||||
.subcommand(Command::new(CMD_DEV)
|
||||
.about("`check` a .roc file, and then run it if there were no errors")
|
||||
|
@ -243,7 +243,7 @@ pub fn build_app() -> Command {
|
|||
.arg(flag_linker.clone())
|
||||
.arg(flag_prebuilt.clone())
|
||||
.arg(roc_file_to_run.clone())
|
||||
.arg(args_for_app.clone())
|
||||
.arg(args_for_app.clone().last(true))
|
||||
)
|
||||
.subcommand(Command::new(CMD_FORMAT)
|
||||
.about("Format a .roc file using standard Roc formatting")
|
||||
|
@ -333,8 +333,8 @@ pub fn build_app() -> Command {
|
|||
.arg(flag_time)
|
||||
.arg(flag_linker)
|
||||
.arg(flag_prebuilt)
|
||||
.arg(roc_file_to_run.required(false))
|
||||
.arg(args_for_app);
|
||||
.arg(roc_file_to_run)
|
||||
.arg(args_for_app.trailing_var_arg(true));
|
||||
|
||||
if cfg!(feature = "editor") {
|
||||
app.subcommand(
|
||||
|
@ -559,7 +559,20 @@ pub fn build(
|
|||
DEFAULT_ROC_FILENAME
|
||||
)
|
||||
}
|
||||
_ => eprintln!("\nThis file was not found: {}\n\nYou can run `roc help` for more information on how to provide a .roc file.\n", expected_file_path_string),
|
||||
_ => {
|
||||
let mut error_lines = Vec::new();
|
||||
error_lines.push(format!(
|
||||
"This file was not found: {}",
|
||||
expected_file_path_string
|
||||
));
|
||||
// Add some additional hints if run as `roc [FILENAME]`.
|
||||
if let None = matches.subcommand() {
|
||||
error_lines.push("Did you misspell a subcommand?".to_string());
|
||||
}
|
||||
error_lines.push("You can run `roc help` to see the list of available subcommands and for more information on how to provide a .roc file.".to_string());
|
||||
|
||||
eprintln!("\n{}\n", error_lines.join("\n\n"));
|
||||
}
|
||||
}
|
||||
|
||||
process::exit(1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue