diff --git a/flake.nix b/flake.nix index e115aa7..953edd1 100644 --- a/flake.nix +++ b/flake.nix @@ -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 = { diff --git a/nu/completions.nu b/nu/completions.nu index 161199c..72c7e8e 100644 --- a/nu/completions.nu +++ b/nu/completions.nu @@ -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"] diff --git a/nu/gen-completions.nu b/nu/gen-completions.nu index a83c439..e69417d 100644 --- a/nu/gen-completions.nu +++ b/nu/gen-completions.nu @@ -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)]"