From 8b2a9928e80ecfa0b4a5f4fff2be6e154aea3780 Mon Sep 17 00:00:00 2001 From: Toothless204 <38069888+Toothless204@users.noreply.github.com> Date: Sun, 2 Feb 2020 11:48:35 +0000 Subject: [PATCH 1/2] added check for - --- src/build/arg/mod.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/build/arg/mod.rs b/src/build/arg/mod.rs index 060b202d..bfefc1a4 100644 --- a/src/build/arg/mod.rs +++ b/src/build/arg/mod.rs @@ -269,6 +269,10 @@ impl<'help> Arg<'help> { /// ``` /// [`short`]: ./struct.Arg.html#method.short pub fn short(mut self, s: char) -> Self { + if s == '-' { + panic!("Invalid option character"); + } + self.short = Some(s); self } From ebdc0453eb0a8d037dc77a7a0cd1d7bd02dc949c Mon Sep 17 00:00:00 2001 From: Toothless204 <38069888+Toothless204@users.noreply.github.com> Date: Sun, 2 Feb 2020 12:19:55 +0000 Subject: [PATCH 2/2] Update src/build/arg/mod.rs make error message more descriptive Co-Authored-By: CreepySkeleton --- src/build/arg/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/build/arg/mod.rs b/src/build/arg/mod.rs index bfefc1a4..41f8ec79 100644 --- a/src/build/arg/mod.rs +++ b/src/build/arg/mod.rs @@ -270,7 +270,7 @@ impl<'help> Arg<'help> { /// [`short`]: ./struct.Arg.html#method.short pub fn short(mut self, s: char) -> Self { if s == '-' { - panic!("Invalid option character"); + panic!("short option name cannot be `-`"); } self.short = Some(s);