63 lines
1.5 KiB
Plaintext
63 lines
1.5 KiB
Plaintext
def settings-db [] {
|
|
$env.HOME | path join ".nxs.db"
|
|
}
|
|
def save [table_name:string] {
|
|
into sqlite (settings-db) --table_name $table_name
|
|
}
|
|
|
|
def query-settings [query:string] {
|
|
print $query
|
|
open (settings-db) | query db $query
|
|
}
|
|
|
|
export def add-host [host:string, working_dir:string] {
|
|
query-settings $"DELETE FROM hosts WHERE host is '($host)'"
|
|
[{host:$host, working_dir: $working_dir}] | save "hosts"
|
|
}
|
|
|
|
export def get-host [host:string] {
|
|
query-settings $"SELECT * FROM hosts WHERE host = '($host)'"
|
|
}
|
|
|
|
export def add-path [section:string, key:string, value:path] {
|
|
[{key:string, value:$value}] | save $section
|
|
}
|
|
|
|
export def add [section:string, key:string, value?:string] {
|
|
[{key:string, value:$value}] | save $section
|
|
}
|
|
|
|
export def set-path [section:string, key:string, value:path] {
|
|
del $section $key
|
|
[{key:$key, value:$value}] | save $section
|
|
}
|
|
|
|
export def set [section:string, key:string, value?:string] {
|
|
del $section $key
|
|
[{key:$key, value:$value}] | save $section
|
|
}
|
|
|
|
export def del [section:string, key:string] {
|
|
query-settings $"DELETE FROM ($section) WHERE key is '($key)'"
|
|
}
|
|
|
|
export def get [section:string@"comp-section-names"] {
|
|
query-settings $"SELECT * FROM ($section)"
|
|
}
|
|
|
|
export def "comp-section-names" [] {
|
|
open (settings-db) | columns
|
|
}
|
|
|
|
export def "comp-project-names" [] {
|
|
get "projects" | select key value | rename value description
|
|
}
|
|
|
|
export def "comp-host-names" [] {
|
|
open (settings-db) | get hosts
|
|
}
|
|
|
|
# print settings
|
|
export def main [] {
|
|
open (settings-db)
|
|
} |