Skip to content

Commit

Permalink
Merge branch 'develop' into enhancement/rework-beta
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushuk committed Oct 5, 2023
2 parents 975f16c + 40dedd9 commit ce6151f
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 0 deletions.
44 changes: 44 additions & 0 deletions pros/cli/conductor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from pros.conductor.templates import ExternalTemplate
from pros.ga.analytics import analytics


@pros_root
def conductor_cli():
pass
Expand Down Expand Up @@ -317,3 +318,46 @@ def info_project(project: c.Project, ls_upgrades):
template["upgrades"] = sorted({t.version for t in templates}, key=lambda v: semver.Version(v), reverse=True)

ui.finalize('project-report', report)

@conductor.command('add-depot')
@click.argument('name')
@click.argument('url')
@default_options
def add_depot(name: str, url: str):
"""
Add a depot
Visit https://pros.cs.purdue.edu/v5/cli/conductor.html to learn more
"""
_conductor = c.Conductor()
_conductor.add_depot(name, url)

ui.echo(f"Added depot {name} from {url}")

@conductor.command('remove-depot')
@click.argument('name')
@default_options
def remove_depot(name: str):
"""
Remove a depot
Visit https://pros.cs.purdue.edu/v5/cli/conductor.html to learn more
"""
_conductor = c.Conductor()
_conductor.remove_depot(name)

ui.echo(f"Removed depot {name}")

@conductor.command('query-depots')
@click.option('--url', is_flag=True)
@default_options
def query_depots(url: bool):
"""
Gets all the stored depots
Visit https://pros.cs.purdue.edu/v5/cli/conductor.html to learn more
"""
_conductor = c.Conductor()
ui.echo(f"Available Depots{' (Add --url for the url)' if not url else ''}:\n")
ui.echo('\n'.join(_conductor.query_depots(url))+"\n")

5 changes: 5 additions & 0 deletions pros/cli/misc_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ def upgrade(force_check, no_install):
"""
Check for updates to the PROS CLI
"""
with ui.Notification():
ui.echo('The "pros upgrade" command is currently non-functioning. Did you mean to run "pros c upgrade"?', color='yellow')

return # Dead code below

analytics.send("upgrade")
from pros.upgrade import UpgradeManager
manager = UpgradeManager()
Expand Down
2 changes: 2 additions & 0 deletions pros/cli/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ def upload(path: Optional[str], project: Optional[c.Project], port: str, **kwarg

# apply upload_options as a template
options = dict(**project.upload_options)
if 'port' in options and port is None:
port = options.get('port', None)
if 'slot' in options and kwargs.get('slot', None) is None:
kwargs.pop('slot')
elif kwargs.get('slot', None) is None:
Expand Down
11 changes: 11 additions & 0 deletions pros/conductor/conductor.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,3 +325,14 @@ def new_project(self, path: str, no_default_libs: bool = False, **kwargs) -> Pro
except Exception as e:
logger(__name__).exception(e)
return proj

def add_depot(self, name: str, url: str):
self.depots[name] = HttpDepot(name, url)
self.save()

def remove_depot(self, name: str):
del self.depots[name]
self.save()

def query_depots(self, url: bool):
return [name + ((' -- ' + depot.location) if url else '') for name, depot in self.depots.items()]
45 changes: 45 additions & 0 deletions pros/conductor/depots.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Adding Depots

`pros conduct add-depot <name-of-your-depot> <https://url-for-your-depot>`

Example:
```bash
$ pros conduct add-depot test "https://pros.cs.purdue.edu/v5/_static/beta/testing-mainline.json"
> Added depot test from https://pros.cs.purdue.edu/v5/_static/beta/testing-mainline.json
```

# Removing Depots

`pros conduct remove-depot <name-of-your-depot>`

Example:
```bash
$ pros conduct remove-depot test
> Removed depot test
```


# Query Depots

`pros conduct query-depots --url`
`pros conduct query-depots`

Examples:
```bash
$ pros conduct query-depots --url
> Available Depots:
>
> kernel-beta-mainline -- https://raw.githubusercontent.com/purduesigbots/pros-mainline/master/beta/kernel-beta-mainline.json
> pros-mainline -- https://purduesigbots.github.io/pros-mainline/pros-mainline.json
> test -- https://pros.cs.purdue.edu/v5/_static/beta/testing-mainline.json
>
```
```bash
$ pros conduct query-depots
> Available Depots (Add --url for the url):
>
> kernel-beta-mainline
> pros-mainline
> test
>
```

0 comments on commit ce6151f

Please sign in to comment.