-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
completion: add
configlet completion
subcommand (#631)
With this commit, running e.g. configlet completion --shell fish will output the fish completion script to stdout. This allows us to distribute completion scripts to the user without adding them to the release assets, which avoids cluttering every directory in which the user runs `fetch-configlet`. For example, the user can enable completions for fish by running: configlet completion -s fish > ~/.config/fish/completions/configlet.fish Closes: #630
- Loading branch information
Showing
5 changed files
with
85 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import std/[os, strformat] | ||
import ../cli | ||
|
||
proc readCompletions: array[Shell, string] = | ||
const repoRootDir = currentSourcePath().parentDir().parentDir().parentDir() | ||
const completionsDir = repoRootDir / "completions" | ||
for shell in sBash .. result.high: | ||
result[shell] = staticRead(completionsDir / &"configlet.{shell}") | ||
|
||
proc completion*(shellKind: Shell) = | ||
const completions = readCompletions() | ||
stdout.write completions[shellKind] |
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