refactor: Renamed envr config init to envr init.

This commit is contained in:
2025-10-28 15:35:46 -04:00
parent 94a572306a
commit 711f3c4a15

43
mod.nu
View File

@@ -84,7 +84,7 @@ def "close db" [] {
rm $dec rm $dec
} }
# Restore a .env file from backup. # Restore a .env file from backup
export def "envr restore" [ export def "envr restore" [
path?: path # The path of the file to restore. Will be prompted if left blank. path?: path # The path of the file to restore. Will be prompted if left blank.
]: nothing -> string { ]: nothing -> string {
@@ -143,27 +143,38 @@ const available_formats = [
] ]
# Create your initial config # Create your initial config
export def "envr config init" [ export def "envr init" [
format?: string format?: string
#identity?: path #identity?: path
] { ] {
mkdir ~/.envr mkdir ~/.envr
let format = if ($format | is-empty) { if (ls ~/.envr/config.* | length | $in > 0) {
$available_formats | input list 'Please select the desired format for your config file' error make {
} msg: "A config file already exists"
label: {
text: "butts"
span: (metadata $format).span
}
}
} else {
let format = if ($format | is-empty) {
$available_formats | input list 'Please select the desired format for your config file'
}
let identity = '~/.ssh/id_ed25519'; let identity = '~/.ssh/id_ed25519';
# The path to the config file. # The path to the config file.
let source = $'~/.envr/config.($format)' let source = $'~/.envr/config.($format)'
{ {
source: $source source: $source
priv_key: $identity priv_key: $identity
pub_key: $'($identity).pub' pub_key: $'($identity).pub'
} | tee { } | tee {
save $source save $source;
open db
}
} }
} }
@@ -187,7 +198,7 @@ export def "envr sync" [] {
} }
# Edit your config # Edit your config
export def "envr config edit" [] { export def "envr edit config" [] {
^$env.EDITOR (config-file) ^$env.EDITOR (config-file)
} }
@@ -196,6 +207,6 @@ def "config-file" []: [nothing -> path nothing -> nothing] {
} }
# show your current config # show your current config
export def "envr config show" []: nothing -> record<source: path, priv_key: path, pub_key: path> { def "envr config show" []: nothing -> record<source: path, priv_key: path, pub_key: path> {
open (config-file) open (config-file)
} }