Only suggest subcommands if not a .roc path

This commit is contained in:
David Smith 2023-05-27 11:25:55 -04:00
parent 3930d117f4
commit b9981ece1e
No known key found for this signature in database
GPG key ID: 979D8D09D9570EED

View file

@ -578,7 +578,8 @@ pub fn build(
)); ));
// Add some additional hints if run as `roc [FILENAME]`. // Add some additional hints if run as `roc [FILENAME]`.
if matches.subcommand().is_none() { if matches.subcommand().is_none() {
if let Some(possible_typo) = path.to_str() { match path.to_str() {
Some(possible_typo) if !possible_typo.ends_with(".roc") => {
if let Some((nearest_command, _)) = if let Some((nearest_command, _)) =
nearest_match(possible_typo, subcommands) nearest_match(possible_typo, subcommands)
{ {
@ -588,6 +589,8 @@ pub fn build(
)); ));
} }
} }
_ => (),
}
} }
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()); 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());