From d74e0646d207dc1c86421fbc101c14fd873f0e9d Mon Sep 17 00:00:00 2001 From: Luca BRUNO Date: Wed, 30 Oct 2019 08:30:10 +0000 Subject: [PATCH] app: quote field names in errors This quotes all field names in errors. It makes easier for humans to disambiguate common network-related cases which currently end up in messages like "address is already in use". --- src/build/app/mod.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/build/app/mod.rs b/src/build/app/mod.rs index 5cf3e6ce..cc3a86dd 100644 --- a/src/build/app/mod.rs +++ b/src/build/app/mod.rs @@ -1466,7 +1466,7 @@ impl<'b> App<'b> { for name in self.args.args.iter().map(|x| x.id) { if self.args.args.iter().filter(|x| x.id == name).count() > 1 { panic!(format!( - "Arg names must be unique, found {} more than once", + "Arg names must be unique, found '{}' more than once", name )); } @@ -1619,7 +1619,7 @@ impl<'b> App<'b> { if let Some(l) = a.long { assert!( self.args.args.iter().filter(|x| x.long == Some(l)).count() < 2, - "Argument long must be unique\n\n\t--{} is already in use", + "Argument long must be unique\n\n\t'--{}' is already in use", l ); } @@ -1628,7 +1628,7 @@ impl<'b> App<'b> { if let Some(s) = a.short { assert!( self.args.args.iter().filter(|x| x.short == Some(s)).count() < 2, - "Argument short must be unique\n\n\t-{} is already in use", + "Argument short must be unique\n\n\t'-{}' is already in use", s ); } @@ -1650,13 +1650,13 @@ impl<'b> App<'b> { if a.is_set(ArgSettings::Last) { assert!( a.long.is_none(), - "Flags or Options may not have last(true) set. {} has both a long and \ + "Flags or Options may not have last(true) set. '{}' has both a long and \ last(true) set.", a.name ); assert!( a.short.is_none(), - "Flags or Options may not have last(true) set. {} has both a short and \ + "Flags or Options may not have last(true) set. '{}' has both a short and \ last(true) set.", a.name );