forked from jotaen/klog
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is an initial effort to address jotaen#177 With this change, klog uses github.com/posener/complete and github.com/willabides/kongplete to generate completions for klog's own commands. There are two coordinated changes that make this feature work: 1. When the `COMP_LINE` environment variable is set, `klog` runs in a special command completion mode. It parses the value of `COMP_LINE` (the current command line), prints to stdout a list of possible completions based on what is on the command line so far, and exits early. 2. `klog completion` prints to stdout a code snippet that defines a completion specification in the current shell. When this code snippet is executed in a shell session, the shell will thereafter invoke the same `klog` executable (with the `COMP_LINE` environment variable set) to generate possible completions. For example, in bash, completions can be enabled by running source <(log completion) Once bash completions are enabled, pressing tab after typing "klog " klog [Tab] will present the available klog commands. In the current implementation, the generated completions are rudimentary and lack ergonomics. There is zero test coverage for this new feature. Because it relies on interaction with the shell, this feature is not easy to test.
- Loading branch information
Showing
4 changed files
with
32 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters