generate: write progress to STDOUT if this is a terminal

This allows usage as:

  eval "$(restic generated --bash-completion /dev/stdout)"
This commit is contained in:
Heiko Schlittermann (HS12-RIPE) 2023-03-22 08:18:08 +01:00
parent bdcafbc11c
commit 087cf7e114
No known key found for this signature in database
GPG Key ID: AF4CC676A6B6C142
1 changed files with 12 additions and 4 deletions

View File

@ -63,22 +63,30 @@ func writeManpages(dir string) error {
}
func writeBashCompletion(file string) error {
Verbosef("writing bash completion file to %v\n", file)
if stdoutIsTerminal() {
Verbosef("writing bash completion file to %v\n", file)
}
return cmdRoot.GenBashCompletionFile(file)
}
func writeFishCompletion(file string) error {
Verbosef("writing fish completion file to %v\n", file)
if stdoutIsTerminal() {
Verbosef("writing fish completion file to %v\n", file)
}
return cmdRoot.GenFishCompletionFile(file, true)
}
func writeZSHCompletion(file string) error {
Verbosef("writing zsh completion file to %v\n", file)
if stdoutIsTerminal() {
Verbosef("writing zsh completion file to %v\n", file)
}
return cmdRoot.GenZshCompletionFile(file)
}
func writePowerShellCompletion(file string) error {
Verbosef("writing powershell completion file to %v\n", file)
if stdoutIsTerminal() {
Verbosef("writing powershell completion file to %v\n", file)
}
return cmdRoot.GenPowerShellCompletionFile(file)
}