fix(config-settings): refuse to open on an empty state dump
An empty dump does not fail loudly: the TUI renders every row as DEFAULT, which is indistinguishable from a config where nothing is set. That is a wrong answer rather than a missing one -- the user would be looking at ON rows reported as DEFAULT -- so the launcher now checks the dump is non-empty and bails with a message instead. The taxonomy alone guarantees output on any working checkout. Also guard a failed mktemp, which would otherwise send the dump to /state and hand an empty path to rm -rf. README: mention that / searches sub-categories across every category.
This commit is contained in:
@@ -331,8 +331,10 @@ Each category further sub-divides into two to six sub-categories with
|
|||||||
their own `__fish_config_op_<category>_<subcategory>` toggles (e.g.
|
their own `__fish_config_op_<category>_<subcategory>` toggles (e.g.
|
||||||
`__fish_config_op_aliases_filesystem`), following the exact same
|
`__fish_config_op_aliases_filesystem`), following the exact same
|
||||||
truthy/falsy/unset cascade one level deeper. Run `config-settings` and
|
truthy/falsy/unset cascade one level deeper. Run `config-settings` and
|
||||||
press Enter on a category row to browse and toggle its sub-categories, or
|
press Enter on a category row to browse and toggle its sub-categories —
|
||||||
see the [Components Reference](https://fish.rootiest.fyi/08-components-reference/)
|
or press `/` and type, which searches sub-categories across every
|
||||||
|
category at once and lists the hits as `Category › Sub`. Or see the
|
||||||
|
[Components Reference](https://fish.rootiest.fyi/08-components-reference/)
|
||||||
for the full sub-category list per category.
|
for the full sub-category list per category.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
@@ -146,7 +146,21 @@ function config-settings --description 'Interactive TUI for managing fish config
|
|||||||
# page's `set -g` land in the caller's shell instead of in a child that is
|
# page's `set -g` land in the caller's shell instead of in a child that is
|
||||||
# about to exit. `command` throughout: this repo's own aliases shadow rm.
|
# about to exit. `command` throughout: this repo's own aliases shadow rm.
|
||||||
set -l work (command mktemp -d)
|
set -l work (command mktemp -d)
|
||||||
|
if test -z "$work" -o ! -d "$work"
|
||||||
|
echo "$c_err""config-settings: could not create a temporary directory.$c_reset" >&2
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
|
||||||
|
# An empty dump would not fail loudly -- the TUI would simply render every
|
||||||
|
# row as DEFAULT, which is indistinguishable from a config where nothing is
|
||||||
|
# set. That is a wrong answer, not a missing one, so refuse instead. The
|
||||||
|
# taxonomy alone guarantees a non-empty dump on any working checkout.
|
||||||
__config_settings_state >$work/state
|
__config_settings_state >$work/state
|
||||||
|
if not test -s $work/state
|
||||||
|
echo "$c_err""config-settings: __config_settings_state produced no output.$c_reset" >&2
|
||||||
|
command rm -rf $work
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
|
||||||
python3 $tui --state $work/state --emit $work/edits
|
python3 $tui --state $work/state --emit $work/edits
|
||||||
set -l rc $status
|
set -l rc $status
|
||||||
|
|||||||
Reference in New Issue
Block a user