3
3
4
4
5
5
def do_pull (repo , fname , branch = "master" , recurse = False ):
6
- click .secho ("Pulling from {} on branch {}" .format (repo , branch ))
6
+ click .secho ("Pulling {} from {} on branch {}" .format (fname , repo , branch ))
7
7
url = "https://raw.githubusercontent.com/"
8
8
url = url + "{}/{}/{}" .format (repo , branch , fname )
9
9
resp = requests .get (url )
@@ -12,19 +12,19 @@ def do_pull(repo, fname, branch="master", recurse=False):
12
12
fh .write (resp .text )
13
13
click .secho ("Saved topology as {}" .format (fname ), fg = "green" )
14
14
return True
15
- elif resp .status_code == 404 and not recurse :
16
- return do_pull (repo , fname , "main" , True )
17
15
else :
18
- click .secho ("Error pulling {} - repo or file not found" .format (repo ), fg = "red" )
16
+ click .secho ("Error pulling {} form {} on branch {} - repo, file, or branch not found" .format (fname , repo , branch ), fg = "red" )
19
17
return False
20
18
21
19
22
20
@click .command ()
23
21
@click .argument ("repo" )
24
- def pull (repo ):
22
+ @click .option ("--file" , default = "topology.yaml" , required = False , help = "Filename to pull (default: topology.yaml)" )
23
+ @click .option ("--branch" , default = "main" , required = False , help = "Branch name from which to pull (default: main)" )
24
+ def pull (repo , file , branch ):
25
25
"""
26
26
pull topology.yaml from repo
27
27
"""
28
- ret = do_pull (repo , "topology.yaml" )
28
+ ret = do_pull (repo , fname = file , branch = branch )
29
29
if not ret :
30
30
exit (1 )
0 commit comments