-
Notifications
You must be signed in to change notification settings - Fork 849
cheat --init should comment out community cheatpath by default #773
Description
Problem
cheat --init outputs a config template with an active community cheatpath pointing at a directory that doesn't exist:
- name: community
path: /home/user/.config/cheat/cheatsheets/community
tags: [ community ]
readonly: trueIf users follow the documented workflow (mkdir -p ~/.config/cheat && cheat --init > ~/.config/cheat/conf.yml) without also cloning the community cheatsheets, the next run of cheat produces a warning:
WARNING: cheatpath '/home/user/.config/cheat/cheatsheets/community' does not exist, skipping
(Prior to v4.5.0 this was a fatal error, not a warning — see #721, #730, #771.)
The installer path (triggered on first run when no config exists) already handles this correctly: it prompts the user about community cheatsheets and comments out the cheatpath if they decline. But --init doesn't prompt — it always outputs the community cheatpath as active.
Proposed solution
Comment out the community cheatpath in --init output by default, with a YAML comment explaining how to enable it:
# To use community cheatsheets, clone them and uncomment the path below:
# git clone https://github.com/cheat/cheatsheets.git /path/to/community
#- name: community
# path: /home/user/.config/cheat/cheatsheets/community
# tags: [ community ]
# readonly: trueThis makes --init produce a config that works out of the box without warnings, while still documenting how to enable community cheatsheets. It matches the behavior of the installer when the user declines community cheatsheets.
Why not make --init interactive?
--init is designed to output to stdout (cheat --init > conf.yml), so adding interactive prompts would mix prompt text into the config file unless carefully separated via stderr. Commenting out the community path by default is simpler and avoids this issue. Users who want the full interactive experience already have it via the first-run installer.
Affected code
cmd/cheat/cmd_init.go— the only file that needs to changecmd/cheat/config.go— the template string (community section needs comment markers)
Acceptance criteria
-
cheat --init > conf.ymlproduces a config with community cheatpath commented out - The commented-out section includes instructions for enabling it (clone URL)
-
cheat --initoutput, when saved as a config file, loads without warnings on subsequent runs - Existing integration test (
TestFirstRunIntegration) continues to pass - Add a test that verifies
--initoutput doesn't contain active community cheatpath
Related issues
- failed to write to pager: exec: "PAGER_PATH": executable file not found in $PATH #721 —
PAGER_PATHplaceholder surviving in config (often caused by bypassing installer) - lstat /home/foo/.config/cheat/cheatsheets: no such file or directory #730 —
lstaterror on missing community cheatsheets directory - no "installer" experience out of the box, just "failed to load config" errors #771 — no installer experience, just errors