Skip to content

Commit

Permalink
added option for dry run
Browse files Browse the repository at this point in the history
  • Loading branch information
mfiers committed Jun 25, 2012
1 parent d756a45 commit b80eca3
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions bin/moar
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ base = os.path.abspath(os.getcwd())
parser = argparse.ArgumentParser(description='run recursively')
parser.add_argument('--bg', dest='background', action='store_true',
default=False,
help='run in the background')
help='run each job in the background')
parser.add_argument('-d', dest='depth', default=0, help='depth: 1 means run only in first ' +
'level subdirs, 2 only in second level, and so on', type=int)
parser.add_argument('-t', dest='test', default=False,
help='test run', action='store_true')
parser.add_argument('command', nargs='+')
args = parser.parse_args()

Expand All @@ -31,7 +33,11 @@ for path, dirs, files in os.walk(base):

if args.depth and args.depth != level:
continue
print 'executing in %s' % localpath

P = sp.Popen(cl, cwd=path, shell=True)
P.wait()
if args.test:
print 'would executed in', localpath
print ' ', cl
else:
print 'executing in %s' % localpath
P = sp.Popen(cl, cwd=path, shell=True)
P.wait()

0 comments on commit b80eca3

Please sign in to comment.