The CLI help message (--help) doesn't keep the original format

Bug #1515713 reported by Markus Zoeller (markus_z)
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
oslo.config
Confirmed
Wishlist
Unassigned

Bug Description

When I create a CLI config option which provides a help text with line
breaks, these line breaks won't get used in the printed help message.

Steps to reproduce
==================
* Create a CLI option which has line breaks in its help text:

    from oslo_config import cfg
    example_opt = cfg.IntOpt('example_opt', default=0,
                             help="""This is an example opt.

    Here is a long description of this example opt which explains this
    more in detail.

    A list which explains things:

    * item 1
    * item 2""")

* Register this CLI opt:

    cfg.register_cli_opt(example_opt, "example_group")

* Let the service which uses this CLI option print its help:

    my-service --help

Expected output
===============

--example_group-example_opt EXAMPLE_GROUP_EXAMPLE_OPT
    This is an example opt.

    Here is a long description of this example opt which explains this
    more in detail.

    A list which explains things:

    * item 1
    * item 2

Actual output
=============

--example_group-example_opt EXAMPLE_GROUP_EXAMPLE_OPT
    This is an example opt. Here is a long description of this example
    opt which explains this more in detail. A list which explains
    things: * item 1 * item 2

Version
=======
* seen in oslo.config version 2.6.0
* NOT double-checked in master code

Notes
=====
I'm using the help extensively in a Nova blueprint [1] and it would be
nice to keep the preformatted text.

References
==========
[1] https://review.openstack.org/#/c/244177/

Changed in oslo.config:
status: New → Confirmed
Revision history for this message
Haifeng.Yan (yanheven) wrote :

seems a big demand.
because oslo.config depends on argparse, including help formatter,
maybe we can push argparse project to add a formatter meet this requirement.

Revision history for this message
Doug Hellmann (doug-hellmann) wrote :

https://docs.python.org/3.5/library/argparse.html#argparse.RawDescriptionHelpFormatter looks like it could be useful here, but that applies to the entire set of arguments. I think we're likely to want to apply the formatting (or not) on a case-by-case basis.

Changed in oslo.config:
importance: Undecided → Wishlist
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.