Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement --last-known-good-version for the install sub command #23

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/c4t/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,4 +459,16 @@ def last_known_good_versions(self) -> List[str]:
installed = ''
print(f'{n} - {channel} version={version}, revision={revision}{installed}')
versions.append(version)
return versions
return versions

def install_last_known_good_version(self) -> None:
versions = self.last_known_good_versions()
try:
selection = int(input('Select a version by number: '))
except ValueError:
selection = None
except IndexError:
selection = None

if selection is not None:
self.install(version=versions[selection])
13 changes: 11 additions & 2 deletions src/c4t/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ def cli() -> None:
help="The version of 'Chrome for Testing' assets to install. " +
"The default is '%(default)s'"
)
sp_install.add_argument(
'-l',
'--last-known-good-version',
action='store_true',
help='Install a last known good version from a list'
)

help_path = 'Show the installation path of assets and exit.'
sub_parsers.add_parser(
Expand Down Expand Up @@ -80,8 +86,11 @@ def cli() -> None:
args = parser.parse_args()

if args.command == 'install':
print(f"Installing version '{args.version}'")
assets.install(version=args.version)
if args.last_known_good_version:
assets.install_last_known_good_version()
else:
print(f"Installing version '{args.version}'")
assets.install(version=args.version)

if args.command == 'path':
print(f'Path to assets: {assets.path}')
Expand Down