From 01574946f5bd7e54baef92738133813ce32481c3 Mon Sep 17 00:00:00 2001 From: Chris Holdgraf Date: Mon, 23 Oct 2017 08:22:12 -0700 Subject: [PATCH 1/3] Re-order arguments to make more intuitive sense --- repo2docker/app.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/repo2docker/app.py b/repo2docker/app.py index 333ac095..80904c24 100644 --- a/repo2docker/app.py +++ b/repo2docker/app.py @@ -137,19 +137,25 @@ class Repo2Docker(Application): help='If building a git url, which ref to check out' ) - argparser.add_argument( - '--push', - dest='push', - action='store_true', - help='Push docker image to repository' - ) - argparser.add_argument( '--debug', help="Turn on debug logging", action='store_true', ) + argparser.add_argument( + '--no-build', + dest='build', + action='store_false', + help="Do not actually build the image. Useful in conjunction with --debug." + ) + + argparser.add_argument( + 'cmd', + nargs='*', + help='Custom command to run after building container' + ) + argparser.add_argument( '--no-run', dest='run', @@ -165,16 +171,10 @@ class Repo2Docker(Application): ) argparser.add_argument( - '--no-build', - dest='build', - action='store_false', - help="Do not actually build the image. Useful in conjunction with --debug." - ) - - argparser.add_argument( - 'cmd', - nargs='*', - help='Custom command to run after building container' + '--push', + dest='push', + action='store_true', + help='Push docker image to repository' ) return argparser From 964fbcf57cf1da5cf794f409a0a44db2f7fa5c78 Mon Sep 17 00:00:00 2001 From: yuvipanda Date: Mon, 23 Oct 2017 08:38:04 -0700 Subject: [PATCH 2/3] Fix handling of 'cmd' nargs='*' made a lot of other parsing fail with strange errors. --- repo2docker/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repo2docker/app.py b/repo2docker/app.py index 80904c24..3d0a734b 100644 --- a/repo2docker/app.py +++ b/repo2docker/app.py @@ -152,7 +152,7 @@ class Repo2Docker(Application): argparser.add_argument( 'cmd', - nargs='*', + action='append', help='Custom command to run after building container' ) From 5f521e21e14c84b5871478fbd363784e5c9e659e Mon Sep 17 00:00:00 2001 From: yuvipanda Date: Mon, 23 Oct 2017 08:53:33 -0700 Subject: [PATCH 3/3] Use argparse.REMAINDER instead of action=append This gathers up all the remaining parameters without misinterpreting parameters like --no-build etc as part of cmd --- repo2docker/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repo2docker/app.py b/repo2docker/app.py index 3d0a734b..82439edc 100644 --- a/repo2docker/app.py +++ b/repo2docker/app.py @@ -152,7 +152,7 @@ class Repo2Docker(Application): argparser.add_argument( 'cmd', - action='append', + nargs=argparse.REMAINDER, help='Custom command to run after building container' )