Added a mutually exclusive group to contain --numwords and --acrostic, addressing...
authorOndkloss <redacted>
Tue, 16 Oct 2018 14:11:47 +0000 (16:11 +0200)
committerOndkloss <redacted>
Tue, 16 Oct 2018 14:22:05 +0000 (16:22 +0200)
xkcdpass/xkcd_password.py

index fe4d8a88a225479f71f1d5a646b0a05b572ae4b3..a0e8b601c629b60cebf107204cab53dbfbc3dab8 100755 (executable)
@@ -396,6 +396,7 @@ class XkcdPassArgumentParser(argparse.ArgumentParser):
 
     def _add_arguments(self):
         """ Add the arguments needed for this program. """
+        exclusive_group = self.add_mutually_exclusive_group()
         self.add_argument(
             "-w", "--wordfile",
             dest="wordfile", default=None, metavar="WORDFILE",
@@ -413,10 +414,14 @@ class XkcdPassArgumentParser(argparse.ArgumentParser):
             "--max",
             dest="max_length", type=int, default=9, metavar="MAX_LENGTH",
             help="Generate passphrases containing at most MAX_LENGTH words.")
-        self.add_argument(
+        exclusive_group.add_argument(
             "-n", "--numwords",
             dest="numwords", type=int, default=6, metavar="NUM_WORDS",
             help="Generate passphrases containing exactly NUM_WORDS words.")
+        exclusive_group.add_argument(
+            "-a", "--acrostic",
+            dest="acrostic", default=False,
+            help="Generate passphrases with an acrostic matching ACROSTIC.")
         self.add_argument(
             "-i", "--interactive",
             action="store_true", dest="interactive", default=False,
@@ -433,10 +438,6 @@ class XkcdPassArgumentParser(argparse.ArgumentParser):
             "-V", "--verbose",
             action="store_true", dest="verbose", default=False,
             help="Report various metrics for given options.")
-        self.add_argument(
-            "-a", "--acrostic",
-            dest="acrostic", default=False,
-            help="Generate passphrases with an acrostic matching ACROSTIC.")
         self.add_argument(
             "-c", "--count",
             dest="count", type=int, default=1, metavar="COUNT",
git clone https://git.99rst.org/PROJECT