Update eval.py, do_cmd.py, delete forline.py.

Forline can be achieved by eval | do_cmd.
This commit is contained in:
voussoir 2020-12-07 17:59:34 -08:00
parent 35281c81ab
commit 34cb53474a
3 changed files with 19 additions and 23 deletions

View file

@ -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)

23
eval.py
View file

@ -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:
def eval_argparse(args):
for line in pipeable.input(args.lines):
x = line
pipeable.output(eval(pattern))
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:]))

View file

@ -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)