[libcxx-commits] [PATCH] D84096: [libcxx][lit] Simplify parsing of trailing executor arguments

Alexander Richardson via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Jul 20 08:05:05 PDT 2020


arichardson updated this revision to Diff 279251.
arichardson added a comment.

remove unnecessary code now that argparse checks that at least one command argument is present


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84096/new/

https://reviews.llvm.org/D84096

Files:
  libcxx/utils/run.py
  libcxx/utils/ssh.py


Index: libcxx/utils/ssh.py
===================================================================
--- libcxx/utils/ssh.py
+++ libcxx/utils/ssh.py
@@ -29,13 +29,9 @@
     parser.add_argument('--execdir', type=str, required=True)
     parser.add_argument('--codesign_identity', type=str, required=False, default=None)
     parser.add_argument('--env', type=str, nargs='*', required=False, default=dict())
-    (args, remaining) = parser.parse_known_args(sys.argv[1:])
-
-    if len(remaining) < 2:
-        sys.stderr.write('Missing actual commands to run')
-        return 1
-
-    commandLine = remaining[1:] # Skip the '--'
+    parser.add_argument("command", nargs=argparse.ONE_OR_MORE)
+    args = parser.parse_args()
+    commandLine = args.command
 
     ssh = lambda command: ['ssh', '-oBatchMode=yes', args.host, command]
     scp = lambda src, dst: ['scp', '-q', '-oBatchMode=yes', src, '{}:{}'.format(args.host, dst)]
Index: libcxx/utils/run.py
===================================================================
--- libcxx/utils/run.py
+++ libcxx/utils/run.py
@@ -23,12 +23,9 @@
     parser.add_argument('--execdir', type=str, required=True)
     parser.add_argument('--codesign_identity', type=str, required=False, default=None)
     parser.add_argument('--env', type=str, nargs='*', required=False, default=dict())
-    (args, remaining) = parser.parse_known_args(sys.argv[1:])
-
-    if len(remaining) < 2:
-        sys.stderr.write('Missing actual commands to run')
-        exit(1)
-    commandLine = remaining[1:] # Skip the '--'
+    parser.add_argument("command", nargs=argparse.ONE_OR_MORE)
+    args = parser.parse_args()
+    commandLine = args.command
 
     # Do any necessary codesigning.
     if args.codesign_identity:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84096.279251.patch
Type: text/x-patch
Size: 1742 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20200720/2ae33e64/attachment.bin>


More information about the libcxx-commits mailing list