Make wrap-logcat a bit easier to call.
Allow the command to be sent in as a non-quoted string.
Test: ./tools/wrap-logcat.py -o /tmp/abc.txt ./test/run-test 001-Main
Change-Id: Ia35c2090c7f0ad8b12ff913a3e1d608e01a56845
diff --git a/tools/wrap-logcat.py b/tools/wrap-logcat.py
index 91bbb25..067890e 100755
--- a/tools/wrap-logcat.py
+++ b/tools/wrap-logcat.py
@@ -35,8 +35,13 @@
finishes.""")
parser.add_argument('command',
action='store',
+ nargs=argparse.REMAINDER,
help='The command to run with logcat in the background.')
args = parser.parse_args()
+ if len(args.command) == 0:
+ print("Must have some command to run.", file=sys.stderr)
+ parser.print_help(file=sys.stderr)
+ return 1
# Send all output from logcat to the file.
with subprocess.Popen(shlex.split(args.logcat_invoke),
stdout=args.output,
@@ -44,7 +49,7 @@
shell=False,
universal_newlines=True) as logcat_proc:
# Let the run-test-proc inherit our stdout FDs
- with subprocess.Popen(shlex.split(args.command),
+ with subprocess.Popen(shlex.split(args.command[0]) if len(args.command) == 1 else args.command,
stdout=None,
stderr=None,
shell=False) as run_test_proc: