perf(cli): 8 new thin handlers — eliminates cli.nu fallback for 20 commands

This commit is contained in:
Jesús Pérez 2026-04-17 22:26:36 +01:00
parent 6df65b5096
commit cd101b060f
Signed by: jesus
GPG key ID: 9F243E355E0BC939
10 changed files with 402 additions and 3 deletions

View file

@ -1055,8 +1055,8 @@ else
workspace | ws) workspace | ws)
$NU "${NU_ARGS[@]}" "$PROVISIONING/core/nulib/main_provisioning/workspace.nu" $CMD_ARGS </dev/null $NU "${NU_ARGS[@]}" "$PROVISIONING/core/nulib/main_provisioning/workspace.nu" $CMD_ARGS </dev/null
;; ;;
env | allenv | list | ls | l | provider | providers | validate | plugin | plugins | nuinfo) env | allenv | list | ls | l | provider | providers | validate | plugin | plugins | nuinfo | config | show)
$NU "${NU_ARGS[@]}" "$PROVISIONING/core/nulib/provisioning-cli.nu" $CMD_ARGS </dev/null $NU "${NU_ARGS[@]}" "$PROVISIONING/core/nulib/provisioning-config.nu" $CMD_ARGS </dev/null
;; ;;
platform | plat | p) platform | plat | p)
# logs needs interactive stdin for typedialog — keep stdin open. # logs needs interactive stdin for typedialog — keep stdin open.
@ -1094,6 +1094,27 @@ else
alias) alias)
$NU "${NU_ARGS[@]}" "$PROVISIONING/core/nulib/provisioning-cli.nu" $CMD_ARGS </dev/null $NU "${NU_ARGS[@]}" "$PROVISIONING/core/nulib/provisioning-cli.nu" $CMD_ARGS </dev/null
;; ;;
orchestrator | orch | o)
$NU "${NU_ARGS[@]}" "$PROVISIONING/core/nulib/provisioning-orchestrator.nu" $CMD_ARGS </dev/null
;;
guide | guides | howto | shortcuts | sc | quickstart | quick | from-scratch | scratch | customize | custom | setup | st)
$NU "${NU_ARGS[@]}" "$PROVISIONING/core/nulib/provisioning-guide.nu" $CMD_ARGS </dev/null
;;
module | mod | layer | lyr | discover | disc)
$NU "${NU_ARGS[@]}" "$PROVISIONING/core/nulib/provisioning-dev.nu" $CMD_ARGS </dev/null
;;
build | bd)
$NU "${NU_ARGS[@]}" "$PROVISIONING/core/nulib/provisioning-build.nu" $CMD_ARGS </dev/null
;;
auth | login | integrations | int)
$NU "${NU_ARGS[@]}" "$PROVISIONING/core/nulib/provisioning-auth.nu" $CMD_ARGS </dev/null
;;
vm)
$NU "${NU_ARGS[@]}" "$PROVISIONING/core/nulib/provisioning-vm.nu" $CMD_ARGS </dev/null
;;
delete | d)
$NU "${NU_ARGS[@]}" "$PROVISIONING/core/nulib/provisioning-delete.nu" $CMD_ARGS
;;
create | new) create | new)
# "prvng create server ..." → "prvng server create ..." # "prvng create server ..." → "prvng server create ..."
shift shift

View file

@ -1,7 +1,7 @@
# Guide Command Handler # Guide Command Handler
# Provides interactive access to guides and cheatsheets # Provides interactive access to guides and cheatsheets
# REMOVED: use lib_provisioning * - causes circular import (already loaded by main provisioning script) use ../../lib_provisioning/utils/interface.nu [_ansi _print]
use ../help_system.nu ["resolve-doc-url"] use ../help_system.nu ["resolve-doc-url"]
# Display condensed cheatsheet summary # Display condensed cheatsheet summary

View file

@ -0,0 +1,48 @@
#!/usr/bin/env nu
# Thin entry for auth | login commands.
# Loads only commands/authentication.nu.
export-env {
let lib_dirs_raw = ($env.NU_LIB_DIRS? | default "")
let current_lib_dirs = if ($lib_dirs_raw | type) == "string" {
if ($lib_dirs_raw | is-empty) { [] } else { ($lib_dirs_raw | split row ":") }
} else { $lib_dirs_raw }
let dynamic = ($env.PROVISIONING? | default "" | path join "core" "nulib")
$env.NU_LIB_DIRS = ([
"/opt/provisioning/core/nulib"
"/usr/local/provisioning/core/nulib"
] | append $current_lib_dirs | append (if ($dynamic | is-not-empty) { [$dynamic] } else { [] }))
let _coerce = {|raw| $raw == "true" or $raw == "1" }
let raw_no_titles = ($env.PROVISIONING_NO_TITLES? | default "")
if ($raw_no_titles | describe) == "string" and ($raw_no_titles | is-not-empty) {
$env.PROVISIONING_NO_TITLES = (do $_coerce $raw_no_titles)
}
let raw_debug = ($env.PROVISIONING_DEBUG? | default "")
if ($raw_debug | describe) == "string" and ($raw_debug | is-not-empty) {
$env.PROVISIONING_DEBUG = (do $_coerce $raw_debug)
}
}
use main_provisioning/flags.nu [parse_common_flags]
use main_provisioning/commands/authentication.nu *
def main [
...args: string
--infra (-i): string = ""
--out: string = ""
--debug (-x)
--yes (-y)
--check (-c)
--notitles
--verbose
]: nothing -> nothing {
if $debug { $env.PROVISIONING_DEBUG = true }
let cmd = ($args | get 0? | default "")
let ops = ($args | skip 1 | str join " ")
let flags = (parse_common_flags {
debug: $debug, out: ($out | default ""), notitles: $notitles,
infra: ($infra | default ""), yes: $yes, check: $check, verbose: $verbose
})
handle_authentication_command $cmd $ops $flags
}

View file

@ -0,0 +1,48 @@
#!/usr/bin/env nu
# Thin entry for build commands.
# Loads only commands/build.nu.
export-env {
let lib_dirs_raw = ($env.NU_LIB_DIRS? | default "")
let current_lib_dirs = if ($lib_dirs_raw | type) == "string" {
if ($lib_dirs_raw | is-empty) { [] } else { ($lib_dirs_raw | split row ":") }
} else { $lib_dirs_raw }
let dynamic = ($env.PROVISIONING? | default "" | path join "core" "nulib")
$env.NU_LIB_DIRS = ([
"/opt/provisioning/core/nulib"
"/usr/local/provisioning/core/nulib"
] | append $current_lib_dirs | append (if ($dynamic | is-not-empty) { [$dynamic] } else { [] }))
let _coerce = {|raw| $raw == "true" or $raw == "1" }
let raw_no_titles = ($env.PROVISIONING_NO_TITLES? | default "")
if ($raw_no_titles | describe) == "string" and ($raw_no_titles | is-not-empty) {
$env.PROVISIONING_NO_TITLES = (do $_coerce $raw_no_titles)
}
let raw_debug = ($env.PROVISIONING_DEBUG? | default "")
if ($raw_debug | describe) == "string" and ($raw_debug | is-not-empty) {
$env.PROVISIONING_DEBUG = (do $_coerce $raw_debug)
}
}
use main_provisioning/flags.nu [parse_common_flags]
use main_provisioning/commands/build.nu *
def main [
...args: string
--infra (-i): string = ""
--out: string = ""
--debug (-x)
--yes (-y)
--check (-c)
--notitles
--verbose
]: nothing -> nothing {
if $debug { $env.PROVISIONING_DEBUG = true }
let cmd = ($args | get 0? | default "")
let ops = ($args | skip 1 | str join " ")
let flags = (parse_common_flags {
debug: $debug, out: ($out | default ""), notitles: $notitles,
infra: ($infra | default ""), yes: $yes, check: $check, verbose: $verbose
})
handle_build_command $cmd $ops $flags
}

View file

@ -0,0 +1,48 @@
#!/usr/bin/env nu
# Thin entry for validate | env | show | config commands.
# Loads only commands/configuration.nu.
export-env {
let lib_dirs_raw = ($env.NU_LIB_DIRS? | default "")
let current_lib_dirs = if ($lib_dirs_raw | type) == "string" {
if ($lib_dirs_raw | is-empty) { [] } else { ($lib_dirs_raw | split row ":") }
} else { $lib_dirs_raw }
let dynamic = ($env.PROVISIONING? | default "" | path join "core" "nulib")
$env.NU_LIB_DIRS = ([
"/opt/provisioning/core/nulib"
"/usr/local/provisioning/core/nulib"
] | append $current_lib_dirs | append (if ($dynamic | is-not-empty) { [$dynamic] } else { [] }))
let _coerce = {|raw| $raw == "true" or $raw == "1" }
let raw_no_titles = ($env.PROVISIONING_NO_TITLES? | default "")
if ($raw_no_titles | describe) == "string" and ($raw_no_titles | is-not-empty) {
$env.PROVISIONING_NO_TITLES = (do $_coerce $raw_no_titles)
}
let raw_debug = ($env.PROVISIONING_DEBUG? | default "")
if ($raw_debug | describe) == "string" and ($raw_debug | is-not-empty) {
$env.PROVISIONING_DEBUG = (do $_coerce $raw_debug)
}
}
use main_provisioning/flags.nu [parse_common_flags]
use main_provisioning/commands/configuration.nu *
def main [
...args: string
--infra (-i): string = ""
--out: string = ""
--debug (-x)
--yes (-y)
--check (-c)
--notitles
--verbose
]: nothing -> nothing {
if $debug { $env.PROVISIONING_DEBUG = true }
let cmd = ($args | get 0? | default "")
let ops = ($args | skip 1 | str join " ")
let flags = (parse_common_flags {
debug: $debug, out: ($out | default ""), notitles: $notitles,
infra: ($infra | default ""), yes: $yes, check: $check, verbose: $verbose
})
handle_configuration_command $cmd $ops $flags
}

View file

@ -0,0 +1,42 @@
#!/usr/bin/env nu
# Thin entry for delete commands (server, taskserv, cluster).
# Loads only main_provisioning/delete.nu (~45ms vs ~3s for cli.nu fallback).
export-env {
let lib_dirs_raw = ($env.NU_LIB_DIRS? | default "")
let current_lib_dirs = if ($lib_dirs_raw | type) == "string" {
if ($lib_dirs_raw | is-empty) { [] } else { ($lib_dirs_raw | split row ":") }
} else { $lib_dirs_raw }
let dynamic = ($env.PROVISIONING? | default "" | path join "core" "nulib")
$env.NU_LIB_DIRS = ([
"/opt/provisioning/core/nulib"
"/usr/local/provisioning/core/nulib"
] | append $current_lib_dirs | append (if ($dynamic | is-not-empty) { [$dynamic] } else { [] }))
let _coerce = {|raw| $raw == "true" or $raw == "1" }
let raw_no_titles = ($env.PROVISIONING_NO_TITLES? | default "")
if ($raw_no_titles | describe) == "string" and ($raw_no_titles | is-not-empty) {
$env.PROVISIONING_NO_TITLES = (do $_coerce $raw_no_titles)
}
let raw_debug = ($env.PROVISIONING_DEBUG? | default "")
if ($raw_debug | describe) == "string" and ($raw_debug | is-not-empty) {
$env.PROVISIONING_DEBUG = (do $_coerce $raw_debug)
}
}
use main_provisioning/delete.nu *
def main [
...args: string
--infra (-i): string = ""
--yes (-y)
--debug (-x)
--keepstorage
--notitles
--wait (-w)
--settings (-s): string = ""
]: nothing -> nothing {
if $debug { $env.PROVISIONING_DEBUG = true }
let target = ($args | get 0? | default "")
let name = ($args | get 1? | default "")
main delete $target $name --infra $infra --yes=$yes --keepstorage=$keepstorage --notitles=$notitles --wait=$wait --settings $settings
}

48
nulib/provisioning-dev.nu Normal file
View file

@ -0,0 +1,48 @@
#!/usr/bin/env nu
# Thin entry for module | layer | discover commands.
# Loads only commands/development.nu.
export-env {
let lib_dirs_raw = ($env.NU_LIB_DIRS? | default "")
let current_lib_dirs = if ($lib_dirs_raw | type) == "string" {
if ($lib_dirs_raw | is-empty) { [] } else { ($lib_dirs_raw | split row ":") }
} else { $lib_dirs_raw }
let dynamic = ($env.PROVISIONING? | default "" | path join "core" "nulib")
$env.NU_LIB_DIRS = ([
"/opt/provisioning/core/nulib"
"/usr/local/provisioning/core/nulib"
] | append $current_lib_dirs | append (if ($dynamic | is-not-empty) { [$dynamic] } else { [] }))
let _coerce = {|raw| $raw == "true" or $raw == "1" }
let raw_no_titles = ($env.PROVISIONING_NO_TITLES? | default "")
if ($raw_no_titles | describe) == "string" and ($raw_no_titles | is-not-empty) {
$env.PROVISIONING_NO_TITLES = (do $_coerce $raw_no_titles)
}
let raw_debug = ($env.PROVISIONING_DEBUG? | default "")
if ($raw_debug | describe) == "string" and ($raw_debug | is-not-empty) {
$env.PROVISIONING_DEBUG = (do $_coerce $raw_debug)
}
}
use main_provisioning/flags.nu [parse_common_flags]
use main_provisioning/commands/development.nu *
def main [
...args: string
--infra (-i): string = ""
--out: string = ""
--debug (-x)
--yes (-y)
--check (-c)
--notitles
--verbose
]: nothing -> nothing {
if $debug { $env.PROVISIONING_DEBUG = true }
let cmd = ($args | get 0? | default "")
let ops = ($args | skip 1 | str join " ")
let flags = (parse_common_flags {
debug: $debug, out: ($out | default ""), notitles: $notitles,
infra: ($infra | default ""), yes: $yes, check: $check, verbose: $verbose
})
handle_development_command $cmd $ops $flags
}

View file

@ -0,0 +1,48 @@
#!/usr/bin/env nu
# Thin entry for guide | shortcuts | quickstart commands.
# Loads only commands/guides.nu.
export-env {
let lib_dirs_raw = ($env.NU_LIB_DIRS? | default "")
let current_lib_dirs = if ($lib_dirs_raw | type) == "string" {
if ($lib_dirs_raw | is-empty) { [] } else { ($lib_dirs_raw | split row ":") }
} else { $lib_dirs_raw }
let dynamic = ($env.PROVISIONING? | default "" | path join "core" "nulib")
$env.NU_LIB_DIRS = ([
"/opt/provisioning/core/nulib"
"/usr/local/provisioning/core/nulib"
] | append $current_lib_dirs | append (if ($dynamic | is-not-empty) { [$dynamic] } else { [] }))
let _coerce = {|raw| $raw == "true" or $raw == "1" }
let raw_no_titles = ($env.PROVISIONING_NO_TITLES? | default "")
if ($raw_no_titles | describe) == "string" and ($raw_no_titles | is-not-empty) {
$env.PROVISIONING_NO_TITLES = (do $_coerce $raw_no_titles)
}
let raw_debug = ($env.PROVISIONING_DEBUG? | default "")
if ($raw_debug | describe) == "string" and ($raw_debug | is-not-empty) {
$env.PROVISIONING_DEBUG = (do $_coerce $raw_debug)
}
}
use main_provisioning/flags.nu [parse_common_flags]
use main_provisioning/commands/guides.nu *
def main [
...args: string
--infra (-i): string = ""
--out: string = ""
--debug (-x)
--yes (-y)
--check (-c)
--notitles
--verbose
]: nothing -> nothing {
if $debug { $env.PROVISIONING_DEBUG = true }
let cmd = ($args | get 0? | default "")
let ops = ($args | skip 1 | str join " ")
let flags = (parse_common_flags {
debug: $debug, out: ($out | default ""), notitles: $notitles,
infra: ($infra | default ""), yes: $yes, check: $check, verbose: $verbose
})
handle_guide_command $cmd $ops $flags
}

View file

@ -0,0 +1,48 @@
#!/usr/bin/env nu
# Thin entry for orchestrator commands.
# Loads only commands/orchestration.nu.
export-env {
let lib_dirs_raw = ($env.NU_LIB_DIRS? | default "")
let current_lib_dirs = if ($lib_dirs_raw | type) == "string" {
if ($lib_dirs_raw | is-empty) { [] } else { ($lib_dirs_raw | split row ":") }
} else { $lib_dirs_raw }
let dynamic = ($env.PROVISIONING? | default "" | path join "core" "nulib")
$env.NU_LIB_DIRS = ([
"/opt/provisioning/core/nulib"
"/usr/local/provisioning/core/nulib"
] | append $current_lib_dirs | append (if ($dynamic | is-not-empty) { [$dynamic] } else { [] }))
let _coerce = {|raw| $raw == "true" or $raw == "1" }
let raw_no_titles = ($env.PROVISIONING_NO_TITLES? | default "")
if ($raw_no_titles | describe) == "string" and ($raw_no_titles | is-not-empty) {
$env.PROVISIONING_NO_TITLES = (do $_coerce $raw_no_titles)
}
let raw_debug = ($env.PROVISIONING_DEBUG? | default "")
if ($raw_debug | describe) == "string" and ($raw_debug | is-not-empty) {
$env.PROVISIONING_DEBUG = (do $_coerce $raw_debug)
}
}
use main_provisioning/flags.nu [parse_common_flags]
use main_provisioning/commands/orchestration.nu *
def main [
...args: string
--infra (-i): string = ""
--out: string = ""
--debug (-x)
--yes (-y)
--check (-c)
--notitles
--verbose
]: nothing -> nothing {
if $debug { $env.PROVISIONING_DEBUG = true }
let cmd = ($args | get 0? | default "")
let ops = ($args | skip 1 | str join " ")
let flags = (parse_common_flags {
debug: $debug, out: ($out | default ""), notitles: $notitles,
infra: ($infra | default ""), yes: $yes, check: $check, verbose: $verbose
})
handle_orchestration_command $cmd $ops $flags
}

48
nulib/provisioning-vm.nu Normal file
View file

@ -0,0 +1,48 @@
#!/usr/bin/env nu
# Thin entry for vm commands.
# Loads only commands/vm_domain.nu.
export-env {
let lib_dirs_raw = ($env.NU_LIB_DIRS? | default "")
let current_lib_dirs = if ($lib_dirs_raw | type) == "string" {
if ($lib_dirs_raw | is-empty) { [] } else { ($lib_dirs_raw | split row ":") }
} else { $lib_dirs_raw }
let dynamic = ($env.PROVISIONING? | default "" | path join "core" "nulib")
$env.NU_LIB_DIRS = ([
"/opt/provisioning/core/nulib"
"/usr/local/provisioning/core/nulib"
] | append $current_lib_dirs | append (if ($dynamic | is-not-empty) { [$dynamic] } else { [] }))
let _coerce = {|raw| $raw == "true" or $raw == "1" }
let raw_no_titles = ($env.PROVISIONING_NO_TITLES? | default "")
if ($raw_no_titles | describe) == "string" and ($raw_no_titles | is-not-empty) {
$env.PROVISIONING_NO_TITLES = (do $_coerce $raw_no_titles)
}
let raw_debug = ($env.PROVISIONING_DEBUG? | default "")
if ($raw_debug | describe) == "string" and ($raw_debug | is-not-empty) {
$env.PROVISIONING_DEBUG = (do $_coerce $raw_debug)
}
}
use main_provisioning/flags.nu [parse_common_flags]
use main_provisioning/commands/vm_domain.nu *
def main [
...args: string
--infra (-i): string = ""
--out: string = ""
--debug (-x)
--yes (-y)
--check (-c)
--notitles
--verbose
]: nothing -> nothing {
if $debug { $env.PROVISIONING_DEBUG = true }
let cmd = ($args | get 0? | default "")
let ops = ($args | skip 1 | str join " ")
let flags = (parse_common_flags {
debug: $debug, out: ($out | default ""), notitles: $notitles,
infra: ($infra | default ""), yes: $yes, check: $check, verbose: $verbose
})
handle_vm_command $cmd $ops $flags
}