Add bash-completion
This commit is contained in:
parent
5edebd57d9
commit
e1b5a89cee
11
.bash-completion
Normal file
11
.bash-completion
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
_ghcup()
|
||||||
|
{
|
||||||
|
local cur
|
||||||
|
COMPREPLY=()
|
||||||
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
|
if [[ ${#COMP_WORDS[*]} -le 2 ]]; then
|
||||||
|
COMPREPLY=($(compgen -W "$(ghcup --list-commands)" -- $cur))
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
} &&
|
||||||
|
complete -F _ghcup ghcup
|
@ -68,6 +68,12 @@ handles your haskell packages and can demand that [a specific version](https://c
|
|||||||
For man pages to work you need [man-db](http://man-db.nongnu.org/) as your `man` provider, then issue `man ghc`. Manpages only work for the currently set ghc.
|
For man pages to work you need [man-db](http://man-db.nongnu.org/) as your `man` provider, then issue `man ghc`. Manpages only work for the currently set ghc.
|
||||||
`MANPATH` may be required to be unset.
|
`MANPATH` may be required to be unset.
|
||||||
|
|
||||||
|
### Bash-completion
|
||||||
|
|
||||||
|
Depending on your distro and setup, install `.bash-completion` from this repo
|
||||||
|
as e.g. `/etc/bash_completion.d/ghcup` and make sure your bashrc sources the
|
||||||
|
startup script (`/usr/share/bash-completion/bash_completion` on some distros).
|
||||||
|
|
||||||
## Design goals
|
## Design goals
|
||||||
|
|
||||||
1. simplicity
|
1. simplicity
|
||||||
|
@ -654,6 +654,12 @@ main = do
|
|||||||
<> help "Show the numeric version (for use in scripts)"
|
<> help "Show the numeric version (for use in scripts)"
|
||||||
<> hidden
|
<> hidden
|
||||||
)
|
)
|
||||||
|
let listCommands = infoOption
|
||||||
|
"install set rm install-cabal list upgrade compile debug-info tool-requirements changelog"
|
||||||
|
( long "list-commands"
|
||||||
|
<> help "List available commands for shell completion"
|
||||||
|
<> internal
|
||||||
|
)
|
||||||
|
|
||||||
let main_footer = [i|Discussion:
|
let main_footer = [i|Discussion:
|
||||||
ghcup installs the Glasgow Haskell Compiler from the official
|
ghcup installs the Glasgow Haskell Compiler from the official
|
||||||
@ -668,7 +674,7 @@ Report bugs at <https://gitlab.haskell.org/haskell/ghcup-hs/issues>|]
|
|||||||
|
|
||||||
customExecParser
|
customExecParser
|
||||||
(prefs showHelpOnError)
|
(prefs showHelpOnError)
|
||||||
(info (opts <**> helper <**> versionHelp <**> numericVersionHelp)
|
(info (opts <**> helper <**> versionHelp <**> numericVersionHelp <**> listCommands)
|
||||||
(footerDoc (Just $ text main_footer))
|
(footerDoc (Just $ text main_footer))
|
||||||
)
|
)
|
||||||
>>= \opt@Options {..} -> do
|
>>= \opt@Options {..} -> do
|
||||||
|
Loading…
Reference in New Issue
Block a user