[opts]: separate code from text in opts_data

- When parsing opts, opts.init() now looks only at string values from
  opts_data.  Global variables are evaluated only when printing help text,
  after the variables are initialized
This commit is contained in:
The MMGen Project 2019-03-26 12:59:30 +00:00
commit 017ecef3bc
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
27 changed files with 385 additions and 247 deletions

View file

@ -30,10 +30,11 @@ os.environ['MMGEN_TEST_SUITE'] = '1'
# Import these _after_ prepending repo_root to sys.path
from mmgen.common import *
opts_data = lambda: {
'desc': "Unit tests for the MMGen suite",
'usage':'[options] [tests]',
'options': """
opts_data = {
'text': {
'desc': "Unit tests for the MMGen suite",
'usage':'[options] [tests]',
'options': """
-h, --help Print this help message
-l, --list List available tests
-n, --names Print command names instead of descriptions
@ -43,6 +44,7 @@ opts_data = lambda: {
'notes': """
If no test is specified, all available tests are run
"""
}
}
sys.argv = [sys.argv[0]] + ['--skip-cfg-file'] + sys.argv[1:]