[PATCH] Format the help text to properly fit to the terminal window
Vratislav Podzimek
vpodzime at redhat.com
Mon May 19 07:52:53 UTC 2014
On Fri, 2014-05-16 at 17:50 +0200, Martin Kolman wrote:
> Provided it is possible to detect the terminal window size.
>
> Signed-off-by: Martin Kolman <mkolman at redhat.com>
> ---
> pyanaconda/anaconda_argparse.py | 28 ++++++++++++++++++++++++++--
> 1 file changed, 26 insertions(+), 2 deletions(-)
>
> diff --git a/pyanaconda/anaconda_argparse.py b/pyanaconda/anaconda_argparse.py
> index 090261d..ac04a35 100644
> --- a/pyanaconda/anaconda_argparse.py
> +++ b/pyanaconda/anaconda_argparse.py
> @@ -26,13 +26,34 @@ DESCRIPTION = "Anaconda is the installation program used by Fedora," \
> import itertools
> import os
>
> -from argparse import ArgumentParser, ArgumentError
> +from argparse import ArgumentParser, ArgumentError, HelpFormatter
>
> from pyanaconda.flags import BootArgs
>
> import logging
> log = logging.getLogger("anaconda")
>
> +# Help text formatting constants
> +
> +LEFT_PADDING = 8 # the help text will start after 8 spaces
> +RIGHT_PADDING = 8 # there will be 8 spaces left on the right
> +HELP_WIDTH = 80
> +
> +# try to detect the terminal window size
> +try:
> + columns = int(os.popen('stty size', 'r').read().split()[1])
Any reference to where this hack comes from? And why not to use the
COLUMNS environmental variable?
--
Vratislav Podzimek
Anaconda Rider | RHCE | Red Hat, Inc. | Brno - Czech Republic
More information about the anaconda-patches
mailing list