This commit is part of a series to retire the Packaging Deb
project. Step 2 is to remove all content from the project
repos, replacing it with a README notification where to find
ongoing work, and how to recover the repo if needed at some
future point (as in
https://docs.openstack.org/infra/manual/drivers.html#retiring-a-project).
Change-Id: I41a3e231882883484b2929706e5ea57616259784
Command base class has provisions to run hooks for a command in
its run() method. We need to do the same for the
DisplayCommandBase class since it does not call super().run()
Change-Id: Ic5481523d4bd919fe7fb10e00330dea2ff688ec4
Change the table formatter to not fit the terminal width by default. Add
a new --fit-width option to turn on that behavior. Width fitting is
implied if the --max-width argument is used. The old behavior can be
restored by setting CLIFF_FIT_WIDTH=1 in the shell environment.
Change-Id: I7b41b38ed25def416605d38c962aea55de842529
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
In some cases, a single documentation build wants to handle multiple
cliff-based CLI. One possible example is openstack-manuals CLI ref.
In this case, the global setting 'autoprogram_cliff_application'
does not work. It is nice if we can specify an application name
per autoprogram-cliff directive.
This commit introduces a new option 'application' to
autoprogram-cliff directive to allow this.
Change-Id: Ie2d01920dc04f2a92031a641d809f7da8af8b395
Set some of the new config values and enable openstackdocstheme as an
extension so it will inject values into the page context as it writes
each documentation page. This ensures the pages link to the right bug
tracker, etc.
Change-Id: I0bc0f1c42e1e54af0dc29d7dfcb23293a3347723
Depends-On: Icf3a40ed104cfd828f532f6f2b112ed02f996ff5
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
Set up the formatter to always use a width=80 so that the terminal width
of the developer's system does not cause the test to fail. Trying to
mock os.environ failed, but there is an arg to HelpFormatter to set the
width explicitly. Unfortunately, there is no way to do that through the
parser, so we have to replace the parser's formatter_class attribute
with a partial() that passes width to the original class.
Change-Id: I2ab035b5b188f1a028e1776ba9f09c71dc316c11
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
Add hooks that are called before and after the take_action() method of
the command.
Change-Id: Id6527dfe0946c0ab169fc165b84d40f3ff95e08c
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
Update Commands to load a separate set of extensions to be used as
"hooks," triggered at different points in the processing of the
command. Start with a hook that is given access to the argument parser
for the command so it can modify it.
Change-Id: I0785548fd36a61cda616921a4a21be3f67701300
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
When the help command instantiates another command class to get its help
text, it needs to pass the command's name if the class supports it.
Change-Id: I3507f723dc8b4e68db80d6da053be61026823457
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
cmd2 0.7.3 started to override Cmd.completenames with a function
taking additional parameters:
Cmd2.completenames(self, text, line, begidx, endidx)
over the Cmd version:
Cmd.completenames(self, text, *ignored)
With this change we adjust the override to the new signature.
Change-Id: I7b110502c20ec16c6032cce31021eee3f85255fc
Closes-Bug: #1700250
The Sphinx 'option' directive only allows optional parameter arguments
to be surrounded by brackets - not positional arguments. As a result,
'cliff.sphinxext' will ignore 'action.metavar' for positional arguments
due to the proclivity of said metavars to include surrounding brackets.
However, 'action.metavar' is sometimes important like, for example, when
'action.metavar' is a singular form but 'action.dest' is a plural form.
This can prove very confusing to users.
Start using 'action.metavar' by stripping out these brackets when they
occur. This ensures we get a pretty good approximation of the intent
without breaking Sphinx.
Change-Id: I114fe551f2a249faa49b419e18a99228627a8e83
We actually initialize the 'ArgumentParser' created in
'Command.get_parser' with the description and epilog values of the
'Command' itself. By using the 'ArgumentParser' value, we can easily
test the parser.
Change-Id: I3bf9de3ce5b8d5aa4adc55155767cb9e7a4ead11
At the moment, the help action (-h, --help) is ignored by default.
However, there is merit in being able to ignore further options. Make it
so.
Change-Id: I924d89fd6b602accac90604a3427b19bd4f9777a
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
At the moment, the 'autoprogram-cliff' directive uses the default usage
formatter in its output. This is functional but no more. Take, for
example, the following output, generated for the python-openstackclient
project:
openstack server migrate [--live <hostname>]
[--shared-migration | --block-migration]
[--disk-overcommit | --no-disk-overcommit] [--wait]
<server>
What we actually want is something like the below, which is not only
more legible but also avoids issues like optional argument flags and
the corresponding values being on separate lines:
openstack server migrate
[--live <hostname>]
[--shared-migration | --block-migration]
[--disk-overcommit | --no-disk-overcommit]
[--wait]
<server>
Do this by manually generating our own usage samples, harnessing a
little of the internal argparse infrastructure.
Change-Id: If4dff4991562da9892f1c06f854143b71111007a
When 'import argparse' is used in cliff.something module,
cliff.argparse is loaded instead of python standard argparse.
This causes cliff.sphinxext failure with no attribute _HelpAction.
This can be avoided by renaming cliff.argparse to non-overlapping
module name like _argparse. cliff.argparse is for internal use,
so I believe it is safe to rename the module.
Closes-Bug: #1692018
Change-Id: Ic34f61581316c662dd2d672bc2c088dcef2100a9
Drop the use of nose in favor of testrepository. Set up the gitignore
rules for the output files.
Add coverage reporting to test jobs.
Update tox.ini so the default environments make sense so it is possible
to just run "tox" for local development.
Change-Id: Ieeffdde3bb8a1869af01f5be2bc682a1a834ba13
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
Some command help messages maybe have multiple line content,
the built-in argparse.HelpFormatter wrap and split the content
according to width, and ignore \n in the raw help message,
it merge multiple line content in one line to output,
that looks messy. SmartHelpFormatter keep the raw help message
format if it contain \n, and wrap long line like HelpFormatter
behavior.
Change-Id: Ib37913891bbf7a31b570404c4668c490d5ac859b
An epilog is text that's displayed after the argument help. It can be
useful to provide some broader context as to the command in question.
This change update the 'sphinxext' plugin to include this in its output.
Change-Id: I7f0bf8ba92dc34cc2e3e9fa2a93ec91ee2f9f8ac
Many projects, such as 'python-openstackclient', manually write
documentation for their cliff-based command line tools. In many cases,
this documentation is a 1:1 reflection of what one could build from the
command line. This is unnecessary overhead that could and should be
avoided.
Add an 'autoprogram-cliff' directive that will allow folks to
automatically document their command line tools.
Change-Id: I497e62382768ffc9668a103706001735a7d851ff
I4bb02749a8fafccaff4ef7ce94ff0c4910fb67e6 fixed cmd2 0.7.0 but
broke <=0.7.0. Detect if Cmd.do_hi() is present to decide what
the response should be to support both cases.
This can be reverted some time after cmd2 0.7.0 is in cliff's
requirements.txt as the minimum version.
Change-Id: I3d42aa68303bed1c302e72d1eab861d355646bc7