- Refactor `installer.clone` into new `repo.Clone` package and method.
- Refactor `sheets.isGitDir` into `repo.GitDir`.
Both of these changes read better, and will facilitate cleaner
architecture when `--update` is implemented.
Integrate `go-git` into the application, and use it to `git clone`
cheatsheets when the installer runs.
Previously, the installer required that `git` be installed on the system
`PATH`, so this change has to big advantages:
1. It removes that system dependency on `git`
2. It paves the way for implementing the `--update` command
Additionally, `cheat` now performs a `--depth=1` clone when installing
cheatsheets, which should at least somewhat improve installation times
(especially on slow network connections).
Fix an issue whereby colorization would output ANSI codes if a pager was
not configured.
The solution here is to stop guessing about the state of the user's
system at runtime, as well as the user's intention. The installer now
chooses an appropriate installer when generating configs, and no longer
bothers searching for pagers at runtime.
Fix an issue whereby ANSI escape characters could appear in search
output when a pager was not configured.
The root cause of the problem was code that was overzealously applying
an underlying effect to search terms.
This commit simply rips out underlying entirely, both as means of
resolving this problem, and also simply for removing needless visual
noise from search output.
Modify `Sheets.Load` to not walk hidden directories like `.git`. This
optimization can potentially prevent thousands of system calls from
being made, because `.git` directories can contain many files.
Bury the `more` pager default on Linux in an effort to work around the
following problem:
https://github.com/cheat/cheat/issues/681#issuecomment-1201842334
We're satisficing for this kludge because it does not appear to be
possible to actually make `more` perform as expected in all
environments.
Fix an issue whereby the installer installed cheatsheets into the wrong
directory on Windows. This occurred because previously `path.Join` was
used where `path/filepath.Join` should have been used.
This matters, because the former always uses `/` as the path separator,
whereas the latter will use `/` or `\` as is appropriate for the
runtime environment.
This should resolve bullet point 4 in #665.
- Update the default config file to use `more` instead of `less` as the
default pager, in order to support Windows out-of-the-box. (#655, #665).
- Use `terminal` Chroma formatter (rather than `terminal16m`) in order
to accommodate less capable terminal emulators like `cmd.exe` by
default. Similarly, default to `colorize: false` in configs (changed
from `true`) (#665).
- Comment out default `style` in order to avoid printing ANSI color
codes into terminals without color support (#665)
- Attempt to intelligently choose a default editor, rather than rely on
a hard-coded `vim` in the configs. This should make it easier to use
`cheat` immediately without needing to specify configs. It should also
improve `cheat`'s Windows compatibility. (#665)
Squashed commit of the following:
commit 5c322e79b7
Author: Chris Lane <chris@chris-allen-lane.com>
Date: Fri Mar 6 19:56:56 2020 -0500
docs(README): update the `README`
Update the `README` to document the improved config-generation
mechanism.
commit 803e1f014c
Author: Chris Lane <chris@chris-allen-lane.com>
Date: Fri Mar 6 19:19:49 2020 -0500
feat(config-init): platform-specific pathing
Update `--init` subcommand to rely upon the same platform-detection
intelligence that was previously implemented by the "installer".
The installer and `--init` should now produce identical config files.
commit 99c48097e2
Author: Chris Lane <chris@chris-allen-lane.com>
Date: Fri Mar 6 18:26:33 2020 -0500
feat(installer): platform-correct config templating
Modify the "installer" to populate cheatpaths with sensible defaults
based on the detection of the user's operating system and environment.
commit 8e1580ff5a
Author: Chris Lane <chris@chris-allen-lane.com>
Date: Thu Mar 5 20:19:58 2020 -0500
fix(tests): fix `config.Paths` tests
Refactor `config.Paths` (by externalizing a call to `homedir.Dir`) to
decouple it from filesystem paths, thus facilitating cleaner unit-tests.
commit a08dca70d9
Author: Chris Lane <chris@chris-allen-lane.com>
Date: Thu Mar 5 18:14:27 2020 -0500
feat(installer): default path selection
Modify the installer to improve default config and cheatsheet path
selection.
commit e15bc6c966
Author: Chris Lane <chris@chris-allen-lane.com>
Date: Thu Mar 5 17:49:50 2020 -0500
fix(typo): correct comment typo in `main.go`
commit efd09575df
Author: Chris Lane <chris@chris-allen-lane.com>
Date: Thu Mar 5 17:46:49 2020 -0500
feat(config): refactor config path detection
Previously, failing other checks, on Unix and BSD systems,
`config.Paths` would attempt to compute the user's home directory by
reading the `HOME` environment variable.
This change deprecates that approach with a call to `homedir.Dir`, which
is used elsewhere throughout the application.
commit ec10244ebe
Author: Chris Lane <chris@chris-allen-lane.com>
Date: Thu Mar 5 17:15:28 2020 -0500
chore(installer): delete unused file
Delete `installer/installer.go`, which (in hindsight) was unnecessary.
commit ebd9ec6287
Author: Chris Lane <chris@chris-allen-lane.com>
Date: Wed Mar 4 19:31:13 2020 -0500
wip(installer): stub experimental "installer"
Stubs out an experimental "installer" that will help new users to
quickly configure `cheat`.
commit ecac5a0971
Author: Chris Lane <chris@chris-allen-lane.com>
Date: Wed Mar 4 19:30:12 2020 -0500
chore(dependencies): updates vendored dependencies
Dramatically improves the usefulness of `--search` by outputting
"chunked" results. This removes the need (usually) to search and then
manually open a cheatsheet.
- Deprecates the `Match` struct
- Applies syntax highlighting to search results output in a manner
consistent with the 'View' output
- Refactors search to move colorization functionality outside of its
concern
Attempts to resolve an issue regarding automatic config file generation,
as referenced in #501. This issue is believed occur when
`XDG_CONFIG_HOME` is unset.
Performs a minor refactoring on `config.Paths` to consistently use
`path.Join` when computing config directory paths. Previously, both
`path.Join` and `fmt.Sprintf` were being used, strictly due to an
oversight.
Fixes an issue whereby the error message generated when a config file
could not be loaded (due to a symlink resolution failure) would fail to
print the config file path to `stderr`.
* feat: directory-scoped cheatpaths
`cheat` now searches for a `.cheat` directory in the current working
directory. If found, that directory is (temporarily) appended to the slice
of cheatpaths.
* makefile wip
* fix: appeases linter
Appeases linter (`go vet`) by adding quotation marks to YAML struct
tags.
* chore: modifies .gitignore
Adds `tag` to `.gitignore`
* feat: adds Makefile
Adds a `Makefile` for managing build-related tasks.
* chore: documents directory-local paths
Adds documentation regarding the new directory-local cheatpath
functionality.
* chore: updates dependencies
* chore: bumps version to 3.3.0
* chore: updates bin scripts
- Removes `build_release.sh`
- Places deprecation notice in `build_devel.sh`, as its purpose has been
superceded by the `Makefile`.
- Corrects an error with `--search`. Previously, `--search` was not
aware of whether it was outputted to a TTY, and would apply colorization
at all times. This resulted in unwanted behavior when, for example,
piping search results into a paginator.
- Corrects an error with `--color`. Previously, `--color` would be
ignored if output was being written to a non-TTY. This made it
impossible, for example, to `cheat tar --color | less -R`, as
colorization would always be stripped. The behavior of `--color` has
been modified such that it now behaves similarly to `--color=always` in
other applications.