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
--host,="${{ inputs.hosts }}"
--flake .
--debug
-vv
--
--keep-going

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -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