diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 553eb58..f2f4343 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -52,6 +52,6 @@ jobs: cache --host,="${{ inputs.hosts }}" --flake . - --debug + -vv -- --keep-going diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index bf6560d..9703181 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -56,7 +56,7 @@ jobs: cache --host,="${{ env.hosts }}" --flake . - --debug + -vv -- --quiet @@ -92,7 +92,7 @@ jobs: ci update --host,="${{ env.hosts }}" --flake . - --debug + -vv -- --quiet diff --git a/pkgs/oizys/src/oizys.nim b/pkgs/oizys/src/oizys.nim index 688fb8a..6cc01ea 100644 --- a/pkgs/oizys/src/oizys.nim +++ b/pkgs/oizys/src/oizys.nim @@ -19,9 +19,10 @@ hwylCli: host: T seq[string] ? "host(s) to build" - debug: - ? "enable debug mode" - - d + verbose: + T Count + ? "increase verbosity (up to 2)" + - v resetCache: ? "set cache timeout to 0" [misc] @@ -33,7 +34,7 @@ hwylCli: - m preSub: setupLoggers() - updateContext(host, flake, debug, resetCache) + updateContext(host, flake, verbose, resetCache) subcommands: [build] @@ -70,7 +71,7 @@ hwylCli: # when really I want it to only happen in the lowest "subcommand" # needs to be fixed in hwylterm preSub: - updateContext(host, flake, debug, resetCache) + updateContext(host, flake, verbose, resetCache) subcommands: [update] ... "build current and updated hosts" @@ -96,7 +97,7 @@ hwylCli: # TODO: support file operations like gh # i.e. @flake.lock means read a file a flake.lock and use it's contents if args.len == 0: fatalQuit "expected workflow file name" - let inputs = + let inputs = inputs.mapIt((it.key, it.val)).toTable() createDispatch(args[0], `ref`, inputs) diff --git a/pkgs/oizys/src/oizys/context.nim b/pkgs/oizys/src/oizys/context.nim index fca6158..400f789 100644 --- a/pkgs/oizys/src/oizys/context.nim +++ b/pkgs/oizys/src/oizys/context.nim @@ -1,6 +1,7 @@ import std/[logging, os, strformat, strutils] from std/nativesockets import getHostname import hwylterm, hwylterm/logging +from hwylterm/hwylcli import Count import ./logging type @@ -9,6 +10,7 @@ type hosts: seq[string] debug: bool ci: bool + verbose: Count resetCache: bool let currentHost* = getHostName() @@ -29,17 +31,17 @@ var oc = initContext() proc checkPath(s: string): string = ## fail if path doesn't exist if not s.dirExists: fatalQuit fmt"flake path: {s} does not exist" - s + result = s proc updateContext*( host: seq[string], flake: string, - debug: bool, + verbose: Count, resetCache: bool ) = if host.len > 0: oc.hosts = host - oc.debug = debug - if debug: + oc.verbose = verbose + if verbose.val > 1: consoleLogger.levelThreshold = lvlAll oc.resetCache = resetCache if flake != "": @@ -49,8 +51,9 @@ proc updateContext*( debug bb(fmt"""[b]flake[/]: {oc.flake}, [b]hosts[/]: {oc.hosts.join(" ")}""") + +proc getVerbosity*(): int = return oc.verbose.val proc getHosts*(): seq[string] = return oc.hosts proc getFlake*(): string = return oc.flake -proc isDebug*(): bool = return oc.debug proc isResetCache*(): bool = return oc.resetCache proc isCi*(): bool = return oc.ci diff --git a/pkgs/oizys/src/oizys/nix.nim b/pkgs/oizys/src/oizys/nix.nim index e8e3477..36fcabe 100644 --- a/pkgs/oizys/src/oizys/nix.nim +++ b/pkgs/oizys/src/oizys/nix.nim @@ -131,8 +131,8 @@ proc display(msg: string, drvs: seq[Derivation]) = for drv in drvs: echo " ", drv.name.trunc(maxLen).alignLeft(maxLen), " ", drv.hash.bb("faint") -proc display(output: DryRunOutput) = - if isDebug(): +proc display(output: DryRunOutput) = + if getVerbosity() > 0: display("to fetch", output.toFetch) else: echo fmt"to fetch: [bold cyan]{output.toFetch.len()}[/]".bb