add --columns long opt

This commit is contained in:
The MMGen Project 2022-05-23 16:28:55 +00:00
commit 43e075db72
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
4 changed files with 11 additions and 4 deletions

View file

@ -116,9 +116,11 @@ class GlobalContext(Lockable):
test_suite = False
test_suite_deterministic = False
test_suite_popen_spawn = False
terminal_width = 0
mnemonic_entry_modes = {}
# display:
columns = 0
color = bool(
( sys.stdout.isatty() and not os.getenv('MMGEN_TEST_SUITE_PEXPECT') ) or
os.getenv('MMGEN_FORCE_COLOR')
@ -166,6 +168,7 @@ class GlobalContext(Lockable):
'bob',
'coin',
'color',
'columns',
'daemon_data_dir',
'daemon_id',
'force_256_color',
@ -233,10 +236,10 @@ class GlobalContext(Lockable):
env_opts = (
'MMGEN_DEBUG_ALL', # special: there is no g.debug_all var
'MMGEN_COLUMNS',
'MMGEN_TEST_SUITE',
'MMGEN_TEST_SUITE_DETERMINISTIC',
'MMGEN_TEST_SUITE_POPEN_SPAWN',
'MMGEN_TERMINAL_WIDTH',
'MMGEN_BOGUS_SEND',
'MMGEN_DEBUG',
'MMGEN_DEBUG_OPTS',

View file

@ -218,6 +218,7 @@ common_opts_data = {
--, --coin=c Choose coin unit. Default: BTC. Current choice: {cu_dfl}
--, --token=t Specify an ERC20 token by address or symbol
--, --color=0|1 Disable or enable color output (enabled by default)
--, --columns=N Force N columns of output with certain commands
--, --force-256-color Force 256-color output when color is enabled
--, --data-dir=path Specify {pnm} data directory location
--, --daemon-data-dir=path Specify coin daemon data directory location
@ -591,6 +592,9 @@ def check_usr_opts(usr_opts): # Raises an exception if any check fails
opt_is_int(val,desc)
opt_compares(int(val),'>',0,desc)
def chk_columns(key,val,desc):
opt_compares(int(val),'>',10,desc)
# TODO: move this check elsewhere
# def chk_token(key,val,desc):
# if not 'token' in proto.caps:

View file

@ -100,7 +100,7 @@ class TwCommon:
def set_term_columns(self):
from ..term import get_terminal_size
while True:
self.cols = g.terminal_width or get_terminal_size().width
self.cols = g.columns or get_terminal_size().width
if self.cols >= g.min_screen_width:
break
line_input(

View file

@ -471,7 +471,7 @@ def create_tmp_dirs(shm_dir):
def set_environ_for_spawned_scripts():
from mmgen.term import get_terminal_size
os.environ['MMGEN_TERMINAL_WIDTH'] = str(get_terminal_size().width)
os.environ['MMGEN_COLUMNS'] = str(get_terminal_size().width)
if os.getenv('MMGEN_DEBUG_ALL'):
for name in g.env_opts: