-
Notifications
You must be signed in to change notification settings - Fork 11
Commandline <> Lib communication using generators #37
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
Changes from all commits
76ec958
7bd5d1e
c9875a3
57f9b74
331679e
7641528
23f6a70
c767b5e
bd635d8
4852eac
107bc48
fb4c6d8
18e4db1
58be926
6d92b92
70a8a4e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,26 +25,13 @@ | |
import click | ||
|
||
import libiocage.lib.Host | ||
import libiocage.lib.Logger | ||
import libiocage.lib.Prompts | ||
import libiocage.lib.Release | ||
import libiocage.lib.errors | ||
|
||
__rootcmd__ = True | ||
|
||
__rootcmd__ = True | ||
|
||
# ToDo: remove disabled feature | ||
# def _prettify_release_names(x): | ||
# if x.name == host.release_version: | ||
# return f"\033[1m{x.name}\033[0m" | ||
# else: | ||
# return x.name | ||
# def release_choice(): | ||
# version = | ||
# return click.Choice(list(map( | ||
# _prettify_release_names, | ||
# host.distribution.releases | ||
# ))) | ||
|
||
@click.command(context_settings=dict( | ||
max_content_width=400, ), | ||
|
@@ -59,8 +46,7 @@ | |
# type=release_choice(), | ||
help="The FreeBSD release to fetch.") | ||
@click.option("--update/--no-update", "-U/-NU", default=True, | ||
help="Decide whether or not to update the fetch to the latest " | ||
"patch level.") | ||
help="Update the release to the latest patch level.") | ||
@click.option("--fetch-updates/--no-fetch-updates", default=True, | ||
help="Skip fetching release updates") | ||
# Compat | ||
|
@@ -70,16 +56,8 @@ | |
@click.option("--files", multiple=True, | ||
help="Specify the files to fetch from the mirror. " | ||
"(Deprecared: renamed to --file)") | ||
@click.option("--log-level", "-d", default=None) | ||
# @click.option("--auth", "-a", default=None, help="Authentication method for " | ||
# "HTTP fetching. Valid " | ||
# "values: basic, digest") | ||
# @click.option("--verify/--noverify", "-V/-NV", default=True, | ||
# help="Enable or disable verifying SSL cert for HTTP fetching.") | ||
# def cli(url, files, release, update): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are we removing current CLI flags? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because they were not implemented yet, so I removed it to clean up the file. Most probably #43 will cause need to re-apply and use this option. I've updated the CLI criteria for signature checking, so that it's not forgotten. |
||
def cli(ctx, **kwargs): | ||
logger = ctx.parent.logger | ||
logger.print_level = kwargs["log_level"] | ||
host = libiocage.lib.Host.Host(logger=logger) | ||
prompts = libiocage.lib.Prompts.Prompts(host=host, logger=logger) | ||
|
||
|
@@ -91,7 +69,7 @@ def cli(ctx, **kwargs): | |
exit(1) | ||
else: | ||
try: | ||
release = libiocage.lib.Release.Release( | ||
release = libiocage.lib.Release.ReleaseGenerator( | ||
name=release_input, | ||
host=host, | ||
logger=logger | ||
|
@@ -100,9 +78,6 @@ def cli(ctx, **kwargs): | |
logger.error(f"Invalid Release '{release_input}'") | ||
exit(1) | ||
|
||
if kwargs["log_level"] is not None: | ||
logger.print_level = kwargs["log_level"] | ||
|
||
url_or_files_selected = False | ||
|
||
if is_option_enabled(kwargs, "url"): | ||
|
@@ -117,28 +92,12 @@ def cli(ctx, **kwargs): | |
logger.error(f"The release '{release.name}' is not available") | ||
exit(1) | ||
|
||
if release.fetched: | ||
msg = f"Release '{release.name}' is already fetched" | ||
if kwargs["update"] is True: | ||
logger.log(f"{msg} - updating only") | ||
else: | ||
logger.log(f"{msg} - skipping download and updates") | ||
exit(0) | ||
else: | ||
logger.log( | ||
f"Fetching release '{release.name}' from '{release.mirror_url}'" | ||
) | ||
release.fetch(update=False, fetch_updates=False) | ||
|
||
if kwargs["fetch_updates"] is True: | ||
logger.log("Fetching updates") | ||
release.fetch_updates() | ||
|
||
if kwargs["update"] is True: | ||
logger.log("Updating release") | ||
release.update() | ||
fetch_updates = bool(kwargs["fetch_updates"]) | ||
ctx.parent.print_events(release.fetch( | ||
update=kwargs["update"], | ||
fetch_updates=fetch_updates | ||
)) | ||
|
||
logger.log('done') | ||
exit(0) | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where are you getting this versioning scheme from? Besides our placeholder release, we haven't discussed versioning much.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started with 0.0.1 and everytime it will introduce new features I'd love to bump the minor version. For breaking changes (after 1.0.0) the major version number will increase. We should discuss and document the versioning system!