Change `config` to `values` for a better name

This commit is contained in:
rwxrob 2021-08-23 22:21:28 -04:00
parent 390b9d1cb6
commit 3f003779db
No known key found for this signature in database
GPG Key ID: 1CCACEDD2F65578E
2 changed files with 13 additions and 12 deletions

View File

@ -83,7 +83,7 @@ cmd config KEY VALUE
``` ```
The `config` command is for reading, writing, and displaying standard The `config` command is for reading, writing, and displaying standard
open desktop configurations properties. open desktop configuration properties.
### Arguments ### Arguments
@ -94,14 +94,14 @@ With a single KEY argument fetches the value for that key and outputs
it. it.
With more than one argument the remaining arguments after the KEY will With more than one argument the remaining arguments after the KEY will
be combined into the VALUE and written to the `config` file in the be combined into the VALUE and written to a `values` file in the
standard configuration home location (Search for `XDG_CONFIG_HOME` for standard configuration home location (Search for `XDG_CONFIG_HOME` for
more information). more information).
### Configuration `config` File Format ### Configuration `config` File Format
The file (which is always named `config` and almost always located at The file (which is almost always located at
`~/.config/cmd/config`) uses the simplest possible format to `~/.config/cmd/values`) uses the simplest possible format to
facilitate standard UNIX parsing and filtering with any number of facilitate standard UNIX parsing and filtering with any number of
existing tools (and no `jq` dependency). existing tools (and no `jq` dependency).
@ -161,5 +161,5 @@ Displays a summary of usage.
---- ----
*Autogenerated Mon Aug 23 10:14:22 PM EDT 2021* *Autogenerated Mon Aug 23 10:21:22 PM EDT 2021*

15
cmd
View File

@ -213,7 +213,7 @@ HELP[config]='
``` ```
The `config` command is for reading, writing, and displaying standard The `config` command is for reading, writing, and displaying standard
open desktop configurations properties. open desktop configuration properties.
### Arguments ### Arguments
@ -224,14 +224,14 @@ With a single KEY argument fetches the value for that key and outputs
it. it.
With more than one argument the remaining arguments after the KEY will With more than one argument the remaining arguments after the KEY will
be combined into the VALUE and written to the `config` file in the be combined into the VALUE and written to a `values` file in the
standard configuration home location (Search for `XDG_CONFIG_HOME` for standard configuration home location (Search for `XDG_CONFIG_HOME` for
more information). more information).
### Configuration `config` File Format ### Configuration `config` File Format
The file (which is always named `config` and almost always located at The file (which is almost always located at
`~/.config/'"$EXE"'/config`) uses the simplest possible format to `~/.config/'"$EXE"'/values`) uses the simplest possible format to
facilitate standard UNIX parsing and filtering with any number of facilitate standard UNIX parsing and filtering with any number of
existing tools (and no `jq` dependency). existing tools (and no `jq` dependency).
@ -269,7 +269,8 @@ _set_config() {
} }
_read_config() { _read_config() {
local path="$XDG_CONFIG_HOME/$EXE/config" local path="$XDG_CONFIG_HOME/$EXE/values"
[[ -r "$path" ]] || return 1
while IFS= read -r line; do while IFS= read -r line; do
[[ $line =~ ^([^=]+)=(.+)$ ]] || continue [[ $line =~ ^([^=]+)=(.+)$ ]] || continue
CONFIG["${BASH_REMATCH[1]}"]="${BASH_REMATCH[2]}" CONFIG["${BASH_REMATCH[1]}"]="${BASH_REMATCH[2]}"
@ -277,8 +278,8 @@ _read_config() {
} }
_write_config() { _write_config() {
local path="$XDG_CONFIG_HOME/$EXE/config" local path="$XDG_CONFIG_HOME/$EXE/values"
mkdir -p "${path%/config}" mkdir -p "${path%/values}"
_dump_config > "$path" _dump_config > "$path"
} }