Commit 14c9f7e2 authored by Mathieu Giraud's avatar Mathieu Giraud

src/should.py: allows options to be read from a configuration file

parent b04912fb
--var
LETTER=l
!OPTIONS: --var DATA=hello --var LETTER=l
!OPTIONS: @demo/variables.cfg --var DATA=hello
# Variables can be defined through options in the command line,
# with a configuration file or within a `!OPTIONS` directive.
# Variables can be used in test commands
# Variables can be used in test commands
echo $DATA
$ Correct test with variables
: hello
# Variables can also be used in test expression
# Variables can also be used in test expressions
$ Variable in text expression given through !OPTIONS
1: $DATA
$ Variable in text expression given through a configuration file
w2: $LETTER
......@@ -82,11 +82,12 @@ for (mod_char, mod_long, mod_help) in MODIFIERS:
# Main argument parser
parser = argparse.ArgumentParser(description='Test .should files',
fromfile_prefix_chars='@',
epilog='''Example:
python3 %(prog)s demo/hello.should''',
formatter_class=argparse.RawTextHelpFormatter)
options = argparse.ArgumentParser() # Can be used in !OPTIONS: directive
options = argparse.ArgumentParser(fromfile_prefix_chars='@') # Can be used in !OPTIONS: directive
for p in (parser, options):
p.add_argument('--mod', action='append', help='modifiers')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment