Skip to content

Commit

Permalink
feat(settings): Make parameter --settings global
Browse files Browse the repository at this point in the history
As we use same settings file for all subcommands it make sense
to make it global, parse in the beginning, and pass to subcommands
already parsed result.

Signed-off-by: Denys Fedoryshchenko <[email protected]>
  • Loading branch information
nuclearcat committed Sep 11, 2024
1 parent f6763e3 commit 09bf3b3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
6 changes: 5 additions & 1 deletion kci-dev/kci-dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@
# -*- coding: utf-8 -*-

import click
from libs.common import *
from subcommands import commit, patch


@click.group(
help="Stand alone tool for Linux Kernel developers and maintainers that can test local Linux Kernel changes on a enabled KernelCI server"
)
@click.version_option("0.0.1", prog_name="kci-dev")
def cli():
@click.option("--settings", default=".kci-dev.toml", help="path of toml setting file")
@click.pass_context
def cli(ctx, settings):
ctx.obj = {"CFG": load_toml(settings)}
pass


Expand Down
8 changes: 3 additions & 5 deletions kci-dev/subcommands/commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import toml
from git import Repo

from libs.common import *


def api_connection(host):
click.secho("api connect: " + host, fg="green")
Expand Down Expand Up @@ -61,9 +59,9 @@ def send_build(url, patch, branch, treeurl, token):
default=".",
help="define the directory of the local tree with local changes",
)
@click.option("--settings", default=".kci-dev.toml", help="path of toml setting file")
def commit(repository, branch, private, path, settings):
config = load_toml(settings)
@click.pass_context
def commit(ctx, repository, branch, private, path):
config = ctx.obj.get("CFG")
url = api_connection(config["connection"]["host"])
diff = find_diff(path, branch, repository)
send_build(url, diff, branch, repository, config["connection"]["token"])
Expand Down
8 changes: 3 additions & 5 deletions kci-dev/subcommands/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import toml
from git import Repo

from libs.common import *


def api_connection(host):
click.secho("api connect: " + host, fg="green")
Expand Down Expand Up @@ -47,9 +45,9 @@ def send_build(url, patch, branch, treeurl, token):
help="define if the test results will be published",
)
@click.option("--patch", required=True, help="mbox or patch file path")
@click.option("--settings", default=".kci-dev.toml", help="path of toml setting file")
def patch(repository, branch, private, patch, settings):
config = load_toml(settings)
@click.pass_context
def patch(ctx, repository, branch, private, patch):
config = ctx.obj.get("CFG")
url = api_connection(config["connection"]["host"])
patch = open(patch, "rb")
send_build(url, patch, branch, repository, config["connection"]["token"])
Expand Down

0 comments on commit 09bf3b3

Please sign in to comment.