cli:add `--man_path` option

This commit is contained in:
Casper da Costa-Luis 2018-10-16 11:24:02 +01:00
parent e53fae537c
commit eeb24eb87f
No known key found for this signature in database
GPG Key ID: 986B408043AE090D
2 changed files with 18 additions and 0 deletions

6
tqdm.1
View File

@ -221,6 +221,12 @@ If true, will count bytes, ignore \f[C]delim\f[], and default
.RS
.RE
.TP
.B \-\-man_path=\f[I]man_path\f[]
str, optional.
Directory in which to install tqdm man pages.
.RS
.RE
.TP
.B \-\-log=\f[I]log\f[]
str, optional.
CRITICAL|FATAL|ERROR|WARN(ING)|[default: \[aq]INFO\[aq]]|DEBUG|NOTSET.

View File

@ -109,6 +109,8 @@ CLI_EXTRA_DOC = r"""
bytes : bool, optional
If true, will count bytes, ignore `delim`, and default
`unit_scale` to True, `unit_divisor` to 1024, and `unit` to 'B'.
man_path : str, optional
Directory in which to install tqdm man pages.
log : str, optional
CRITICAL|FATAL|ERROR|WARN(ING)|[default: 'INFO']|DEBUG|NOTSET.
"""
@ -189,6 +191,16 @@ Options:
buf_size = tqdm_args.pop('buf_size', 256)
delim = tqdm_args.pop('delim', '\n')
delim_per_char = tqdm_args.pop('bytes', False)
man_path = tqdm_args.pop('man_path', None)
if man_path is not None:
from os import path
from shutil import copyfile
fi = path.dirname(path.dirname(path.abspath(__file__)))
fi = path.join(fi, 'tqdm.1')
fo = path.join(man_path, 'tqdm.1')
copyfile(fi, fo)
log.info("written:" + fo)
sys.exit(0)
if delim_per_char:
tqdm_args.setdefault('unit', 'B')
tqdm_args.setdefault('unit_scale', True)