diff --git a/do_cmd.py b/do_cmd.py index 10e573b..4a40c66 100644 --- a/do_cmd.py +++ b/do_cmd.py @@ -2,6 +2,5 @@ import os from voussoirkit import pipeable - -for line in pipeable.go(): +for line in pipeable.go(strip=True, skip_blank=True): os.system(line) diff --git a/eval.py b/eval.py index 3928aa3..f0d2dcf 100644 --- a/eval.py +++ b/eval.py @@ -1,3 +1,4 @@ +import argparse import glob import math import os @@ -7,10 +8,6 @@ import sys from voussoirkit import pipeable - -lines = pipeable.input(sys.argv[1]) -pattern = sys.argv[2] - def quote(s): return '"%s"' % s @@ -23,6 +20,20 @@ def random_hex(length=12): token = token[:length] return token -for line in lines: - x = line - pipeable.output(eval(pattern)) +def eval_argparse(args): + for line in pipeable.input(args.lines): + x = line + pipeable.output(eval(args.eval_string)) + +def main(argv): + parser = argparse.ArgumentParser(description=__doc__) + + parser.add_argument('lines') + parser.add_argument('eval_string') + parser.set_defaults(func=eval_argparse) + + args = parser.parse_args(argv) + return args.func(args) + +if __name__ == '__main__': + raise SystemExit(main(sys.argv[1:])) diff --git a/forline.py b/forline.py deleted file mode 100644 index e21fe63..0000000 --- a/forline.py +++ /dev/null @@ -1,14 +0,0 @@ -import os -import sys - -from voussoirkit import clipext - -text = sys.argv[1] -command = sys.argv[2:] -command = ['"%s"' % x if (' ' in x or x == '%x') else x for x in command] -command = ' '.join(command) -text = clipext.resolve(text) - -for line in text.splitlines(): - thiscomm = command.replace('%x', line) - os.system(thiscomm)