summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorDolph Mathews <dolph.mathews@gmail.com>2017-03-30 18:24:31 +0000
committerStephen Finucane <sfinucan@redhat.com>2017-03-30 18:24:31 +0000
commit18d1617caa5a7380e2298b1e647ef110c9d574be (patch)
tree33e99a42aa2eb35ada1bccd9020c8267046ee450 /doc
parentec84eeda526adc20dcabdf6e704958cc06773dd3 (diff)
downloadoslo-config-18d1617caa5a7380e2298b1e647ef110c9d574be.tar.gz
Assume positional arguments are required
The 'positional' keyword specifically applies to oslo.config's argparse support. Unlike oslo.config, argparse assumes that all positional arguments are required by default, and you have to explicitly tell it that a positional argument is optional if you'd like to opt into that behavior. This patch adopts that same behavior for oslo.config. When you define an option to be non-positional (oslo.config's default, designed for config files), then oslo.config makes that option optional: However, when you define an option to be positional, oslo.config assumes that the option is primarily going to be used on the CLI and thus sets it as required, by default. This change in behavior has the side effect of allowing argparse to enforce required arguments on the CLI *while* parsing arguments, instead of depending on oslo.config to detect the condition *after* argparse has been allowed to parse "invalid" arguments. argparse correctly raises a SystemExit in this case, and prints the actual command usage and a "hey, you forgot this required argument", instead of allowing oslo.config to dump a backtrace to the CLI with a context-less error message ("context-less" in that no useful CLI usage information is dumped along with the crash to help you correct the condition). Change-Id: Ifdc6918444fe72f7e1649483c237cce64b4c72d8 Partial-Bug: 1676989
Diffstat (limited to 'doc')
-rw-r--r--doc/source/reference/command-line.rst4
1 files changed, 4 insertions, 0 deletions
diff --git a/doc/source/reference/command-line.rst b/doc/source/reference/command-line.rst
index 169b4ba..5a4cbbb 100644
--- a/doc/source/reference/command-line.rst
+++ b/doc/source/reference/command-line.rst
@@ -17,6 +17,10 @@ constructor argument:
>>> conf.bar
['a', 'b']
+By default, positional arguments are also required. You may opt-out of this
+behavior by setting ``required=False``, to have an optional positional
+argument.
+
Sub-Parsers
-----------