Fix argparsing error, path in file not found log, panic on invalid args

This commit is contained in:
Juno Takano 2025-12-14 15:26:49 -03:00
commit 294c15baa6
3 changed files with 4 additions and 8 deletions

View file

@ -6,7 +6,7 @@ _default:
# Build on changes # Build on changes
[group('dev')] [group('dev')]
serve-watch: serve-watch:
bacon --job run-long -- -- --host localhost --port 3003 bacon --job run-long -- -- --hostname localhost --port 3003
alias sw := serve-watch alias sw := serve-watch
alias dev := serve-watch alias dev := serve-watch

View file

@ -12,7 +12,7 @@ pub async fn file(file_path: &str, content_type: &str) -> Response<Body> {
let content = match std::fs::read(file_path) { let content = match std::fs::read(file_path) {
Ok(s) => s, Ok(s) => s,
Err(e) => { Err(e) => {
panic!("[file_handler] Failed to read file contents: {e}") panic!("Failed to read {file_path} contents: {e}")
}, },
}; };

View file

@ -37,7 +37,7 @@ fn parse(defaults: &Arguments, args: &[String]) -> Arguments {
for arg in filtered_args.chunks(2) { for arg in filtered_args.chunks(2) {
if let Some(argument) = arg.first() if let Some(argument) = arg.first()
&& let Some(parameter) = arg.last() && let Some(parameter) = arg.get(1)
{ {
if argument.eq("-h") || argument.eq("--hostname") { if argument.eq("-h") || argument.eq("--hostname") {
out_args.hostname = String::from(parameter); out_args.hostname = String::from(parameter);
@ -52,11 +52,7 @@ fn parse(defaults: &Arguments, args: &[String]) -> Arguments {
); );
} }
} else { } else {
crate::dev::log( panic!("Argument {arg:?} has no corresponding value")
&parse,
"Dropped: Couldn't pair either one of or
both argument \"{argument}\", parameter \"{parameter}\"",
);
} }
} }
out_args out_args