new flag syntax

This commit is contained in:
Daylin Morgan 2025-02-19 15:06:26 -06:00
parent 8b6b8227db
commit 2193da713a
Signed by: daylin
GPG key ID: 950D13E9719334AD
4 changed files with 24 additions and 66 deletions

View file

@ -10,7 +10,7 @@ buildNimblePackage {
version = "unstable"; version = "unstable";
src = lib.cleanSource ./.; src = lib.cleanSource ./.;
nativeBuildInputs = [ openssl]; nativeBuildInputs = [ openssl];
nimbleDepsHash = "sha256-bthmRlUO6IOYRiwVic0TPOvo0gsfD/49J2GzoIQqlF0="; nimbleDepsHash = "sha256-ZNS/ak5UoH3cvOAnRdCoovo/20A8woxowa5wefluU5g=";
meta = { meta = {
description = "nix begat oizys"; description = "nix begat oizys";
}; };

View file

@ -3,12 +3,12 @@
"packages": { "packages": {
"hwylterm": { "hwylterm": {
"version": "0.1.0", "version": "0.1.0",
"vcsRevision": "6a6bd269f2dc385b5711b1a29246883144bccb4f", "vcsRevision": "1324ba54151eeb6c2a28d8236854ccfb9885b530",
"url": "https://github.com/daylinmorgan/hwylterm", "url": "https://github.com/daylinmorgan/hwylterm",
"downloadMethod": "git", "downloadMethod": "git",
"dependencies": [], "dependencies": [],
"checksums": { "checksums": {
"sha1": "e484311567eca66268ebe2ffd9dbb768025277ae" "sha1": "b5c3cc2e8ed4ce5514750d1216d0816cd4ef0dc7"
} }
}, },
"jsony": { "jsony": {

View file

@ -13,5 +13,5 @@ bin = @["oizys"]
requires "nim >= 2.0.8" requires "nim >= 2.0.8"
requires "jsony" requires "jsony"
requires "zippy" requires "zippy"
requires "https://github.com/daylinmorgan/hwylterm#6a6bd269" requires "https://github.com/daylinmorgan/hwylterm#1324ba54"
requires "https://github.com/daylinmorgan/resultz#43ed7f7e" requires "https://github.com/daylinmorgan/resultz#43ed7f7e"

View file

@ -14,33 +14,18 @@ hwylCli:
settings ShowHelp settings ShowHelp
flags: flags:
[global] [global]
flake: flake(string, "path/to/flake")
T string host(seq[string], "host(s) to build")
? "path/to/flake" v|verbose(Count(val:0), Count, "increase verbosity (up to 2)")
host: `reset-cache`("set cache timeout to 0")
T seq[string] b|bootstrap("enable bootstrap mode")
? "host(s) to build"
verbose:
T Count
? "increase verbosity (up to 2)"
- v
* Count(val: 0)
`reset-cache`:
? "set cache timeout to 0"
ident resetCache
bootstrap:
? "enable bootstrap mode"
- b
[misc] [misc]
yes: y|yes "skip all confirmation prompts"
- y m|minimal "set minimal"
? "skip all confirmation prompts"
minimal:
? "set minimal"
- m
preSub: preSub:
setupLoggers() setupLoggers()
updateContext(host, flake, verbose, resetCache, bootstrap) updateContext(host, flake, verbose, `reset-cache`, bootstrap)
subcommands: subcommands:
[build] [build]
@ -49,8 +34,7 @@ hwylCli:
args seq[string] args seq[string]
flags: flags:
^minimal ^minimal
nom: nom "use nom"
? "use nom"
run: run:
nixBuild(minimal, nom, args) nixBuild(minimal, nom, args)
@ -59,22 +43,10 @@ hwylCli:
positionals: positionals:
args seq[string] args seq[string]
flags: flags:
name: name("nix-cache.dayl.in", string, "name/host of binary cache")
T string service("store", string, "name of cache service")
? "name/host of binary cache" j|jobs(countProcessors(),int, "jobs when pushing paths")
* "nix-cache.dayl.in" n|`dry-run` "don't actually build derivations"
service:
T string
? "name of cache service"
* "store"
jobs:
T int
? "jobs when pushing paths"
* countProcessors()
- j
`dry-run`:
- n
? "don't actually build derivations"
run: run:
nixBuildWithCache(name, args, service, jobs, `dry-run`) nixBuildWithCache(name, args, service, jobs, `dry-run`)
@ -98,13 +70,8 @@ hwylCli:
positionals: positionals:
workflow string workflow string
flags: flags:
inputs: inputs(seq[KVString], "inputs for dispatch")
T seq[KVString] `ref`("main", string, "git ref/branch/tag to trigger workflow on")
? "inputs for dispatch"
`ref`:
T string
? "git ref/branch/tag to trigger workflow on"
* "main"
run: run:
# TODO: support file operations like gh # TODO: support file operations like gh
# i.e. @flake.lock means read a file at flake.lock and use it's contents as a string # i.e. @flake.lock means read a file at flake.lock and use it's contents as a string
@ -127,9 +94,7 @@ hwylCli:
subcmd NixosRebuildSubcmd subcmd NixosRebuildSubcmd
args seq[string] args seq[string]
flags: flags:
remote: r|remote "host is remote"
? "host is remote"
- r
run: run:
nixosRebuild(subcmd, args, remote) nixosRebuild(subcmd, args, remote)
@ -137,9 +102,7 @@ hwylCli:
... "nixos config attr" ... "nixos config attr"
flags: flags:
^minimal ^minimal
system: s|system "show system path"
? "show system path"
- s
run: run:
if minimal and system: if minimal and system:
echo "--minimal and --system are mutually exclusive" echo "--minimal and --system are mutually exclusive"
@ -155,9 +118,7 @@ hwylCli:
... "update and run nixos-rebuild" ... "update and run nixos-rebuild"
flags: flags:
^yes ^yes
preview: p|preview "show preview and exit"
? "show preview and exit"
- p
run: run:
let hosts = getHosts() let hosts = getHosts()
if hosts.len > 1: fatalQuit "operation only supports one host" if hosts.len > 1: fatalQuit "operation only supports one host"
@ -188,9 +149,7 @@ hwylCli:
positionals: positionals:
installables seq[string] installables seq[string]
flags: flags:
cache: c|cache(seq[string], "url of nix binary cache, can be repeated")
? "url of nix binary cache, can be repeated"
T seq[string]
run: run:
if installables.len == 0: if installables.len == 0:
fatalQuit "expected at least one positional argument" fatalQuit "expected at least one positional argument"
@ -203,7 +162,6 @@ hwylCli:
currently just runs `jq < flake.lock '.nodes | keys[] | select(contains("_"))' -r` currently just runs `jq < flake.lock '.nodes | keys[] | select(contains("_"))' -r`
""" """
run: run:
# use absolute value for flake.lock?
if not isLocal(): if not isLocal():
quit "`oizys lock` should be run with a local flake" quit "`oizys lock` should be run with a local flake"