25 lines
985 B
Text
25 lines
985 B
Text
use platform/setup/mod.nu [setup_config_path]
|
|
|
|
export def setup_user_context_path [defaults_name: string = "context.yaml"] {
|
|
let str_filename = if ($defaults_name | into string) == "" { "context.yaml" } else { $defaults_name }
|
|
let filename = if ($str_filename | str ends-with ".yaml") {
|
|
$str_filename
|
|
} else {
|
|
$"($str_filename).yaml"
|
|
}
|
|
let setup_context_path = (setup_config_path | path join $filename)
|
|
if ($setup_context_path | path exists) { $setup_context_path } else { "" }
|
|
}
|
|
|
|
export def setup_user_context [defaults_name: string = "context.yaml"] {
|
|
let setup_context_path = setup_user_context_path $defaults_name
|
|
if $setup_context_path == "" { return null }
|
|
open $setup_context_path
|
|
}
|
|
|
|
export def setup_save_context [data: record, defaults_name: string = "context.yaml"] {
|
|
let setup_context_path = setup_user_context_path $defaults_name
|
|
if $setup_context_path != "" {
|
|
$data | save -f $setup_context_path
|
|
}
|
|
}
|