nufmt after generation
This commit is contained in:
1 parent
b1c6a52503
commit
e07ae98c0b
3 files changed
+57
-55
No files matched your search
@@ -100,14 +100,14 @@
|
||||
|
||||
git-hooks.hooks = {
|
||||
# Format all .nu files with nufmt.
|
||||
# nufmt = {
|
||||
# enable = true;
|
||||
# name = "nufmt";
|
||||
# entry = "${pkgs.nufmt}/bin/nufmt";
|
||||
# language = "system";
|
||||
# types = [ "file" ];
|
||||
# files = "\\.nu$";
|
||||
# };
|
||||
nufmt = {
|
||||
enable = true;
|
||||
name = "nufmt";
|
||||
entry = "${pkgs.nufmt}/bin/nufmt";
|
||||
language = "system";
|
||||
types = [ "file" ];
|
||||
files = "\\.nu$";
|
||||
};
|
||||
|
||||
# Regenerate nu/completions.nu whenever a usage block changes.
|
||||
gen-completions = {
|
||||
|
||||
+47
-47
@@ -8,65 +8,65 @@
|
||||
# sourcing needed.
|
||||
|
||||
def "nu-complete hermenix top" [] {
|
||||
[
|
||||
[value description];
|
||||
[setup "guided host-side setup"]
|
||||
[migrate "carry an existing flat HERMES_HOME into the guest"]
|
||||
[remote "run setup/migrate on a remote host over SSH"]
|
||||
[vm "control the VM (start/stop/console/snapshots/backups)"]
|
||||
[ctl "drive Hermes inside the guest (identity/config/secrets/gateway)"]
|
||||
]
|
||||
[
|
||||
[value, description];
|
||||
[setup, "guided host-side setup"]
|
||||
[migrate, "carry an existing flat HERMES_HOME into the guest"]
|
||||
[remote, "run setup/migrate on a remote host over SSH"]
|
||||
[vm, "control the VM (start/stop/console/snapshots/backups)"]
|
||||
[ctl, "drive Hermes inside the guest (identity/config/secrets/gateway)"]
|
||||
]
|
||||
}
|
||||
|
||||
def "nu-complete hermenix vm" [] {
|
||||
[
|
||||
[value description];
|
||||
[ssh "open a shell or run a single command in the guest"]
|
||||
[console "follow the VM's journal output (journalctl -f)"]
|
||||
[start "systemctl start hermes-vm"]
|
||||
[stop "systemctl stop hermes-vm"]
|
||||
[restart "systemctl restart hermes-vm"]
|
||||
[config "show current generation, history and git status"]
|
||||
[config-pull "copy the guest's /etc/nixos here for reading/diffing"]
|
||||
[snapshot "trigger a state-disk snapshot now"]
|
||||
[snapshots "list existing snapshots"]
|
||||
[rollback "restore the state disk from a snapshot"]
|
||||
[backup "trigger a restic backup now"]
|
||||
[backups "list restic snapshots"]
|
||||
]
|
||||
[
|
||||
[value, description];
|
||||
[ssh, "open a shell or run a single command in the guest"]
|
||||
[console, "follow the VM's journal output (journalctl -f)"]
|
||||
[start, "systemctl start hermes-vm"]
|
||||
[stop, "systemctl stop hermes-vm"]
|
||||
[restart, "systemctl restart hermes-vm"]
|
||||
[config, "show current generation, history and git status"]
|
||||
[config-pull, "copy the guest's /etc/nixos here for reading/diffing"]
|
||||
[snapshot, "trigger a state-disk snapshot now"]
|
||||
[snapshots, "list existing snapshots"]
|
||||
[rollback, "restore the state disk from a snapshot"]
|
||||
[backup, "trigger a restic backup now"]
|
||||
[backups, "list restic snapshots"]
|
||||
]
|
||||
}
|
||||
|
||||
def "nu-complete hermenix ctl" [] {
|
||||
[
|
||||
[value description];
|
||||
[soul "show or edit SOUL.md"]
|
||||
[memory "show or edit memories/USER.md"]
|
||||
[conf "show or edit config.yaml"]
|
||||
[secrets "manage .env (keys masked by default)"]
|
||||
[status "gateway service status"]
|
||||
[logs "follow gateway journal (-f)"]
|
||||
[restart "restart the gateway"]
|
||||
[units "list all hermes* user units"]
|
||||
[reseed "overwrite identity from /etc/nixos/hermes"]
|
||||
[pull "copy live identity back to the host"]
|
||||
]
|
||||
[
|
||||
[value, description];
|
||||
[soul, "show or edit SOUL.md"]
|
||||
[memory, "show or edit memories/USER.md"]
|
||||
[conf, "show or edit config.yaml"]
|
||||
[secrets, "manage .env (keys masked by default)"]
|
||||
[status, "gateway service status"]
|
||||
[logs, "follow gateway journal (-f)"]
|
||||
[restart, "restart the gateway"]
|
||||
[units, "list all hermes* user units"]
|
||||
[reseed, "overwrite identity from /etc/nixos/hermes"]
|
||||
[pull, "copy live identity back to the host"]
|
||||
]
|
||||
}
|
||||
|
||||
# Context-aware completer: inspects already-typed words to decide
|
||||
# whether to offer top-level subcommands or a second-level list.
|
||||
def "nu-complete hermenix ctx" [context: string, offset: int] {
|
||||
let words = $context | str trim | split row " " | where { $in != "" }
|
||||
match ($words | length) {
|
||||
1 => (nu-complete hermenix top)
|
||||
2 => {
|
||||
match ($words | get 1) {
|
||||
"vm" => (nu-complete hermenix vm)
|
||||
"ctl" => (nu-complete hermenix ctl)
|
||||
_ => []
|
||||
}
|
||||
let words = $context | str trim | split row " " | where { $in != "" }
|
||||
match ($words | length) {
|
||||
1 => (nu-complete hermenix top)
|
||||
2 => {
|
||||
match ($words | get 1) {
|
||||
"vm" => (nu-complete hermenix vm)
|
||||
"ctl" => (nu-complete hermenix ctl)
|
||||
_ => []
|
||||
}
|
||||
}
|
||||
_ => []
|
||||
}
|
||||
_ => []
|
||||
}
|
||||
}
|
||||
|
||||
extern "hermenix" [...args: string@"nu-complete hermenix ctx"]
|
||||
@@ -143,4 +143,6 @@ if ($ctl | is-empty) { print -e "warn: no ctl completions found in ctl/ctl.nu" }
|
||||
""
|
||||
] | str join "\n" | save -f $out_file
|
||||
|
||||
nufmt $out_file
|
||||
|
||||
print $"wrote ($out_file) [top=($top | length) vm=($vm | length) ctl=($ctl | length)]"
|
||||
Reference in new issue
Block a user