Skip to content

Commit

Permalink
Add get branchline template commands
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushuk committed Feb 29, 2024
1 parent dcd5376 commit 4ff9c64
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions pros/cli/conductor_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,37 @@ def publish_template(name: str, version: str, token: str):

ui.echo("Published template");

@conductor.command('get-branchline-templates')
def get_branchline_templates():
"""
Get templates list from branchline
"""
# url = 'https://pros.cs.purdue.edu/v5/_static/branchline/pros-branchline.json'
url = 'https://raw.githubusercontent.com/purduesigbots/pros-branchline/HEAD/pros-branchline.json'
import requests
response = requests.get(url)
print(response.text)

@conductor.command('get-branchline-template-versions')
@click.argument('name')
def get_branchline_template_versions(name: str):
"""
Get branchline template versions
"""
versions_url = f'https://raw.githubusercontent.com/purduesigbots/pros-branchline/HEAD/templates/{name}.json'
versions = requests.get(versions_url).json()
print(versions)

templates_url = 'https://raw.githubusercontent.com/purduesigbots/pros-branchline/HEAD/pros-branchline.json'
templates = requests.get(templates_url).json()

repository = ''
for entry in templates:
if entry['name'] == name:
repository = entry['repository']

readme_url = f'https://raw.githubusercontent.com/{repository}/HEAD/README.md'
readme = requests.get(readme_url).text
versions.append(readme)
print(versions)

0 comments on commit 4ff9c64

Please sign in to comment.