Skip to content

Commit c80eb2e

Browse files
authored
Merge pull request #317 from purduesigbots/release/3.5.0
🔖 Release 3.5.0
2 parents fb7e006 + 246a884 commit c80eb2e

File tree

13 files changed

+250
-92
lines changed

13 files changed

+250
-92
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ jobs:
1616
- name: Update Build Number
1717
id: step1
1818
run: |
19+
git describe --tags
20+
git clean -f
1921
python3 version.py
2022
echo "::set-output name=test::$(cat version)"
2123

pros/cli/click_classes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
from collections import defaultdict
22
from typing import *
33

4+
from rich_click import RichCommand
45
import click.decorators
56
from click import ClickException
67
from pros.conductor.project import Project as p
78
from pros.common.utils import get_version
89

910

10-
class PROSFormatted(click.BaseCommand):
11+
class PROSFormatted(RichCommand):
1112
"""
1213
Common format functions used in the PROS derived classes. Derived classes mix and match which functions are needed
1314
"""

pros/cli/common.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ def resolve_v5_port(port: Optional[str], type: str, quiet: bool = False) -> Tupl
244244
is_joystick = False
245245
if not port:
246246
ports = find_v5_ports(type)
247+
logger(__name__).debug('Ports: {}'.format(';'.join([str(p.__dict__) for p in ports])))
247248
if len(ports) == 0:
248249
if not quiet:
249250
logger(__name__).error('No {0} ports were found! If you think you have a {0} plugged in, '
@@ -252,8 +253,10 @@ def resolve_v5_port(port: Optional[str], type: str, quiet: bool = False) -> Tupl
252253
return None, False
253254
if len(ports) > 1:
254255
if not quiet:
255-
port = click.prompt('Multiple {} ports were found. Please choose one: '.format('v5'),
256+
port = click.prompt('Multiple {} ports were found. Please choose one: [{}]'
257+
.format('v5', '|'.join([p.device for p in ports])),
256258
default=ports[0].device,
259+
show_default=False,
257260
type=click.Choice([p.device for p in ports]))
258261
assert port in [p.device for p in ports]
259262
else:

pros/cli/conductor.py

Lines changed: 62 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from pros.conductor.templates import ExternalTemplate
88
from pros.ga.analytics import analytics
99

10+
1011
@pros_root
1112
def conductor_cli():
1213
pass
@@ -90,8 +91,8 @@ def fetch(query: c.BaseTemplate):
9091
help="Force apply the template, disregarding if the template is already installed.")
9192
@click.option('--remove-empty-dirs/--no-remove-empty-dirs', 'remove_empty_directories', is_flag=True, default=True,
9293
help='Remove empty directories when removing files')
93-
@click.option('--beta', is_flag=True, default=False, show_default=True,
94-
help='Allow applying beta templates')
94+
@click.option('--early-access/--disable-early-access', '--early/--disable-early', '-ea/-dea', 'early_access', '--beta/--disable-beta', default=None,
95+
help='Create a project using the PROS 4 kernel')
9596
@project_option()
9697
@template_query(required=True)
9798
@default_options
@@ -116,8 +117,6 @@ def apply(project: c.Project, query: c.BaseTemplate, **kwargs):
116117
help="Force apply the template, disregarding if the template is already installed.")
117118
@click.option('--remove-empty-dirs/--no-remove-empty-dirs', 'remove_empty_directories', is_flag=True, default=True,
118119
help='Remove empty directories when removing files')
119-
@click.option('--beta', is_flag=True, default=False, show_default=True,
120-
help='Allow applying beta templates')
121120
@project_option()
122121
@template_query(required=True)
123122
@default_options
@@ -143,8 +142,8 @@ def install(ctx: click.Context, **kwargs):
143142
help="Force apply the template, disregarding if the template is already installed.")
144143
@click.option('--remove-empty-dirs/--no-remove-empty-dirs', 'remove_empty_directories', is_flag=True, default=True,
145144
help='Remove empty directories when removing files')
146-
@click.option('--beta', is_flag=True, default=False, show_default=True,
147-
help='Allow upgrading to beta templates')
145+
@click.option('--early-access/--disable-early-access', '--early/--disable-early', '-ea/-dea', 'early_access', '--beta/--disable-beta', default=None,
146+
help='Create a project using the PROS 4 kernel')
148147
@project_option()
149148
@template_query(required=False)
150149
@default_options
@@ -205,8 +204,8 @@ def uninstall_template(project: c.Project, query: c.BaseTemplate, remove_user: b
205204
help='Compile the project after creation')
206205
@click.option('--build-cache', is_flag=True, default=None, show_default=False,
207206
help='Build compile commands cache after creation. Overrides --compile-after if both are specified.')
208-
@click.option('--beta', is_flag=True, default=False, show_default=True,
209-
help='Create a project with a beta template')
207+
@click.option('--early-access/--disable-early-access', '--early/--disable-early', '-ea/-dea', 'early_access', '--beta/--disable-beta', default=None,
208+
help='Create a project using the PROS 4 kernel')
210209
@click.pass_context
211210
@default_options
212211
def new_project(ctx: click.Context, path: str, target: str, version: str,
@@ -218,6 +217,7 @@ def new_project(ctx: click.Context, path: str, target: str, version: str,
218217
Visit https://pros.cs.purdue.edu/v5/cli/conductor.html to learn more
219218
"""
220219
analytics.send("new-project")
220+
version_source = version.lower() == 'latest'
221221
if version.lower() == 'latest' or not version:
222222
version = '>0'
223223
if not force_system and c.Project.find_project(path) is not None:
@@ -228,7 +228,7 @@ def new_project(ctx: click.Context, path: str, target: str, version: str,
228228
_conductor = c.Conductor()
229229
if target is None:
230230
target = _conductor.default_target
231-
project = _conductor.new_project(path, target=target, version=version,
231+
project = _conductor.new_project(path, target=target, version=version, version_source=version_source,
232232
force_user=force_user, force_system=force_system,
233233
no_default_libs=no_default_libs, **kwargs)
234234
ui.echo('New PROS Project was created:', output_machine=False)
@@ -237,7 +237,10 @@ def new_project(ctx: click.Context, path: str, target: str, version: str,
237237
if compile_after or build_cache:
238238
with ui.Notification():
239239
ui.echo('Building project...')
240-
ctx.exit(project.compile([], scan_build=build_cache))
240+
exit_code = project.compile([], scan_build=build_cache)
241+
if exit_code != 0:
242+
logger(__name__).error(f'Failed to make project: Exit Code {exit_code}', extra={'sentry': False})
243+
raise click.ClickException('Failed to build')
241244

242245
except Exception as e:
243246
pros.common.logger(__name__).exception(e)
@@ -255,13 +258,13 @@ def new_project(ctx: click.Context, path: str, target: str, version: str,
255258
help='Force update all remote depots, ignoring automatic update checks')
256259
@click.option('--limit', type=int, default=15,
257260
help='The maximum number of displayed results for each library')
258-
@click.option('--beta', is_flag=True, default=False, show_default=True,
259-
help='View beta templates in the listing')
261+
@click.option('--early-access/--disable-early-access', '--early/--disable-early', '-ea/-dea', 'early_access', '--beta/--disable-beta', default=None,
262+
help='View a list of early access templates')
260263
@template_query(required=False)
261264
@click.pass_context
262265
@default_options
263266
def query_templates(ctx, query: c.BaseTemplate, allow_offline: bool, allow_online: bool, force_refresh: bool,
264-
limit: int, beta: bool):
267+
limit: int, early_access: bool):
265268
"""
266269
Query local and remote templates based on a spec
267270
@@ -271,10 +274,10 @@ def query_templates(ctx, query: c.BaseTemplate, allow_offline: bool, allow_onlin
271274
if limit < 0:
272275
limit = 15
273276
templates = c.Conductor().resolve_templates(query, allow_offline=allow_offline, allow_online=allow_online,
274-
force_refresh=force_refresh, beta=beta)
275-
if beta:
277+
force_refresh=force_refresh, early_access=early_access)
278+
if early_access:
276279
templates += c.Conductor().resolve_templates(query, allow_offline=allow_offline, allow_online=allow_online,
277-
force_refresh=force_refresh, beta=False)
280+
force_refresh=force_refresh, early_access=False)
278281

279282
render_templates = {}
280283
for template in templates:
@@ -323,3 +326,46 @@ def info_project(project: c.Project, ls_upgrades):
323326
template["upgrades"] = sorted({t.version for t in templates}, key=lambda v: semver.Version(v), reverse=True)
324327

325328
ui.finalize('project-report', report)
329+
330+
@conductor.command('add-depot')
331+
@click.argument('name')
332+
@click.argument('url')
333+
@default_options
334+
def add_depot(name: str, url: str):
335+
"""
336+
Add a depot
337+
338+
Visit https://pros.cs.purdue.edu/v5/cli/conductor.html to learn more
339+
"""
340+
_conductor = c.Conductor()
341+
_conductor.add_depot(name, url)
342+
343+
ui.echo(f"Added depot {name} from {url}")
344+
345+
@conductor.command('remove-depot')
346+
@click.argument('name')
347+
@default_options
348+
def remove_depot(name: str):
349+
"""
350+
Remove a depot
351+
352+
Visit https://pros.cs.purdue.edu/v5/cli/conductor.html to learn more
353+
"""
354+
_conductor = c.Conductor()
355+
_conductor.remove_depot(name)
356+
357+
ui.echo(f"Removed depot {name}")
358+
359+
@conductor.command('query-depots')
360+
@click.option('--url', is_flag=True)
361+
@default_options
362+
def query_depots(url: bool):
363+
"""
364+
Gets all the stored depots
365+
366+
Visit https://pros.cs.purdue.edu/v5/cli/conductor.html to learn more
367+
"""
368+
_conductor = c.Conductor()
369+
ui.echo(f"Available Depots{' (Add --url for the url)' if not url else ''}:\n")
370+
ui.echo('\n'.join(_conductor.query_depots(url))+"\n")
371+

pros/cli/main.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import pros.common.sentry
88

99
import click
10+
import ctypes
1011
import sys
1112

1213
import pros.common.ui as ui
@@ -27,6 +28,10 @@
2728
import pros.cli.interactive
2829
import pros.cli.user_script
2930

31+
if sys.platform == 'win32':
32+
kernel32 = ctypes.windll.kernel32
33+
kernel32.SetConsoleMode(kernel32.GetStdHandle(-11), 7)
34+
3035
root_sources = [
3136
'build',
3237
'conductor',
@@ -63,7 +68,7 @@ def main():
6368
.format(version = get_version()), ctx_obj)
6469
click_handler.setFormatter(formatter)
6570
logging.basicConfig(level=logging.WARNING, handlers=[click_handler])
66-
cli.main(prog_name='pros', obj=ctx_obj)
71+
cli.main(prog_name='pros', obj=ctx_obj, windows_expand_args=False)
6772
except KeyboardInterrupt:
6873
click.echo('Aborted!')
6974
except Exception as e:

pros/cli/misc_commands.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ def upgrade(force_check, no_install):
1717
"""
1818
Check for updates to the PROS CLI
1919
"""
20+
with ui.Notification():
21+
ui.echo('The "pros upgrade" command is currently non-functioning. Did you mean to run "pros c upgrade"?', color='yellow')
22+
23+
return # Dead code below
24+
2025
analytics.send("upgrade")
2126
from pros.upgrade import UpgradeManager
2227
manager = UpgradeManager()

pros/cli/upload.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ def upload(path: Optional[str], project: Optional[c.Project], port: str, **kwarg
7070

7171
# apply upload_options as a template
7272
options = dict(**project.upload_options)
73+
if 'port' in options and port is None:
74+
port = options.get('port', None)
7375
if 'slot' in options and kwargs.get('slot', None) is None:
7476
kwargs.pop('slot')
7577
elif kwargs.get('slot', None) is None:

0 commit comments

Comments
 (0)