debug -> verbosity

This commit is contained in:
Daylin Morgan 2025-01-07 15:48:32 -06:00
parent eecde6f7da
commit c74e07801c
Signed by: daylin
GPG key ID: 950D13E9719334AD
5 changed files with 20 additions and 16 deletions

View file

@ -52,6 +52,6 @@ jobs:
cache cache
--host,="${{ inputs.hosts }}" --host,="${{ inputs.hosts }}"
--flake . --flake .
--debug -vv
-- --
--keep-going --keep-going

View file

@ -56,7 +56,7 @@ jobs:
cache cache
--host,="${{ env.hosts }}" --host,="${{ env.hosts }}"
--flake . --flake .
--debug -vv
-- --
--quiet --quiet
@ -92,7 +92,7 @@ jobs:
ci update ci update
--host,="${{ env.hosts }}" --host,="${{ env.hosts }}"
--flake . --flake .
--debug -vv
-- --
--quiet --quiet

View file

@ -19,9 +19,10 @@ hwylCli:
host: host:
T seq[string] T seq[string]
? "host(s) to build" ? "host(s) to build"
debug: verbose:
? "enable debug mode" T Count
- d ? "increase verbosity (up to 2)"
- v
resetCache: resetCache:
? "set cache timeout to 0" ? "set cache timeout to 0"
[misc] [misc]
@ -33,7 +34,7 @@ hwylCli:
- m - m
preSub: preSub:
setupLoggers() setupLoggers()
updateContext(host, flake, debug, resetCache) updateContext(host, flake, verbose, resetCache)
subcommands: subcommands:
[build] [build]
@ -70,7 +71,7 @@ hwylCli:
# when really I want it to only happen in the lowest "subcommand" # when really I want it to only happen in the lowest "subcommand"
# needs to be fixed in hwylterm # needs to be fixed in hwylterm
preSub: preSub:
updateContext(host, flake, debug, resetCache) updateContext(host, flake, verbose, resetCache)
subcommands: subcommands:
[update] [update]
... "build current and updated hosts" ... "build current and updated hosts"

View file

@ -1,6 +1,7 @@
import std/[logging, os, strformat, strutils] import std/[logging, os, strformat, strutils]
from std/nativesockets import getHostname from std/nativesockets import getHostname
import hwylterm, hwylterm/logging import hwylterm, hwylterm/logging
from hwylterm/hwylcli import Count
import ./logging import ./logging
type type
@ -9,6 +10,7 @@ type
hosts: seq[string] hosts: seq[string]
debug: bool debug: bool
ci: bool ci: bool
verbose: Count
resetCache: bool resetCache: bool
let currentHost* = getHostName() let currentHost* = getHostName()
@ -29,17 +31,17 @@ var oc = initContext()
proc checkPath(s: string): string = proc checkPath(s: string): string =
## fail if path doesn't exist ## fail if path doesn't exist
if not s.dirExists: fatalQuit fmt"flake path: {s} does not exist" if not s.dirExists: fatalQuit fmt"flake path: {s} does not exist"
s result = s
proc updateContext*( proc updateContext*(
host: seq[string], host: seq[string],
flake: string, flake: string,
debug: bool, verbose: Count,
resetCache: bool resetCache: bool
) = ) =
if host.len > 0: oc.hosts = host if host.len > 0: oc.hosts = host
oc.debug = debug oc.verbose = verbose
if debug: if verbose.val > 1:
consoleLogger.levelThreshold = lvlAll consoleLogger.levelThreshold = lvlAll
oc.resetCache = resetCache oc.resetCache = resetCache
if flake != "": if flake != "":
@ -49,8 +51,9 @@ proc updateContext*(
debug bb(fmt"""[b]flake[/]: {oc.flake}, [b]hosts[/]: {oc.hosts.join(" ")}""") 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 getHosts*(): seq[string] = return oc.hosts
proc getFlake*(): string = return oc.flake proc getFlake*(): string = return oc.flake
proc isDebug*(): bool = return oc.debug
proc isResetCache*(): bool = return oc.resetCache proc isResetCache*(): bool = return oc.resetCache
proc isCi*(): bool = return oc.ci proc isCi*(): bool = return oc.ci

View file

@ -132,7 +132,7 @@ proc display(msg: string, drvs: seq[Derivation]) =
echo " ", drv.name.trunc(maxLen).alignLeft(maxLen), " ", drv.hash.bb("faint") echo " ", drv.name.trunc(maxLen).alignLeft(maxLen), " ", drv.hash.bb("faint")
proc display(output: DryRunOutput) = proc display(output: DryRunOutput) =
if isDebug(): if getVerbosity() > 0:
display("to fetch", output.toFetch) display("to fetch", output.toFetch)
else: else:
echo fmt"to fetch: [bold cyan]{output.toFetch.len()}[/]".bb echo fmt"to fetch: [bold cyan]{output.toFetch.len()}[/]".bb