Skip to content

Commit e5774b4

Browse files
committed
Add support for flexible files and branches.
1 parent f0258bc commit e5774b4

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

virl/cli/pull/commands.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44

55
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))
77
url = "https://raw.githubusercontent.com/"
88
url = url + "{}/{}/{}".format(repo, branch, fname)
99
resp = requests.get(url)
@@ -12,19 +12,19 @@ def do_pull(repo, fname, branch="master", recurse=False):
1212
fh.write(resp.text)
1313
click.secho("Saved topology as {}".format(fname), fg="green")
1414
return True
15-
elif resp.status_code == 404 and not recurse:
16-
return do_pull(repo, fname, "main", True)
1715
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")
1917
return False
2018

2119

2220
@click.command()
2321
@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):
2525
"""
2626
pull topology.yaml from repo
2727
"""
28-
ret = do_pull(repo, "topology.yaml")
28+
ret = do_pull(repo, fname=file, branch=branch)
2929
if not ret:
3030
exit(1)

0 commit comments

Comments
 (0)