@@ -81,7 +81,7 @@ def unpack(sproj, branch):
81
81
shutil .rmtree (os .path .join (outdir , '.git' ))
82
82
os .unlink (ofilename )
83
83
84
- def install (sproj ):
84
+ def install (sproj , requested_branch = None ):
85
85
if not os .path .isdir (spdir ):
86
86
print ('Run this in your source root and make sure there is a subprojects directory in it.' )
87
87
return 1
@@ -90,23 +90,39 @@ def install(sproj):
90
90
blist = [b for b in blist if b != 'master' ]
91
91
blist .sort ()
92
92
branch = blist [- 1 ]
93
+ if requested_branch is not None :
94
+ if requested_branch in blist :
95
+ branch = requested_branch
96
+ else :
97
+ print ('Could not find user-requested branch' , requested_branch )
98
+ print ('Available branches for' , sproj , ':' )
99
+ print (blist )
100
+ return 1
93
101
print ('Using branch' , branch )
94
102
return unpack (sproj , branch )
95
103
104
+ def print_help ():
105
+ print ('Usage:' )
106
+ print (sys .argv [0 ], 'list' )
107
+ print (sys .argv [0 ], 'install' , 'package_name' , '[branch_name]' )
108
+
96
109
def run (args ):
97
110
if not args or args [0 ] == '-h' or args [0 ] == '--help' :
98
- print ( sys . argv [ 0 ], 'list/install' , 'package_name' )
111
+ print_help ( )
99
112
return 1
100
113
command = args [0 ]
101
114
args = args [1 :]
102
115
if command == 'list' :
103
116
list_projects ()
104
117
return 0
105
118
elif command == 'install' :
106
- if len (args ) != 1 :
107
- print ('Install requires exactly one argument.' )
119
+ if len (args ) == 1 :
120
+ return install (args [0 ])
121
+ elif len (args ) == 2 :
122
+ return install (args [0 ], args [1 ])
123
+ else :
124
+ print_help ()
108
125
return 1
109
- return install (args [0 ])
110
126
else :
111
127
print ('Unknown command' )
112
128
return 1
0 commit comments