Skip to content

Commit

Permalink
Merge pull request #23 from p4irin/feature/install-version-from-last-…
Browse files Browse the repository at this point in the history
…known-good-versions-list

Implement --last-known-good-version for the install sub command
  • Loading branch information
p4irin committed May 2, 2024
2 parents 5ff6903 + 0e85da6 commit e0c4e66
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
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

0 comments on commit e0c4e66

Please sign in to comment.