Skip to content

Commit

Permalink
Merge pull request #10 from linuxlizard/dpoole/add-dry-run-option
Browse files Browse the repository at this point in the history
first pass of -n (aka dry-run) option
  • Loading branch information
linuxlizard committed Jul 7, 2023
2 parents ab6463b + 538c3ac commit 45e77b2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
13 changes: 10 additions & 3 deletions pymake/pargs.py
Expand Up @@ -25,6 +25,9 @@ def usage():
-h
--help
Print this help message and exit.
-n
--just-print, --dry-run, --recon
Don't run any recipes, just print them.
-r
--no-builtin-rules
Disable reading GNU Make's built-in rules.
Expand Down Expand Up @@ -75,6 +78,8 @@ def __init__(self):
# -C aka --directory option
self.directory = None

self.dry_run = False

self.warn_undefined_variables = False
self.detailed_error_explain = False

Expand All @@ -83,21 +88,21 @@ def parse_args(argv):
Copyright (C) 2014-2023 David Poole davep@mbuf.com, testcluster@gmail.com""" % (Version.vstring(),)

args = Args()
optlist, arglist = getopt.gnu_getopt(argv, "Bhvo:drSf:C:",
optlist, arglist = getopt.gnu_getopt(argv, "Bhvo:drSf:C:n",
[
"help",
"always-make",
"debug",
"dotfile=",
"html=",
"explain",
"file=",
"makefile=",
"file=", "makefile=",
"output=",
"no-builtin-rules",
"version",
"warn-undefined-variables",
"directory=",
"just-print", "dry-run", "recon"
]
)
for opt in optlist:
Expand Down Expand Up @@ -132,6 +137,8 @@ def parse_args(argv):
if args.directory is None:
args.directory = []
args.directory.append(opt[1])
elif opt[0] in ('-n', '--just-print', '--dry-run', '--recon'):
args.dry_run = True
else:
# wtf?
assert 0, opt
Expand Down
13 changes: 13 additions & 0 deletions tests/test_args.py
Expand Up @@ -85,3 +85,16 @@ def test_multiple_directory():
assert len(args.directory)==2
assert args.directory[0] == 'build'
assert args.directory[1] == 'docs'

def test_dry_run():
args = pargs.parse_args(('-n',),)
assert args.dry_run

args = pargs.parse_args(('--just-print',),)
assert args.dry_run

args = pargs.parse_args(('--dry-run',),)
assert args.dry_run

args = pargs.parse_args(('--recon',),)
assert args.dry_run

0 comments on commit 45e77b2

Please sign in to comment.