zsh-completion: added escapinng of single quotes in flag description.
This commit is contained in:
committed by
Steve Francia
parent
66a98807d4
commit
8822449c0f
@ -139,7 +139,7 @@ func genFlagEntryForSingleOptionFlag(f *pflag.Flag) string {
|
||||
}
|
||||
extras = genZshFlagEntryExtras(f)
|
||||
|
||||
return fmt.Sprintf(`'%s%s[%s]%s'`, multiMark, option, f.Usage, extras)
|
||||
return fmt.Sprintf(`'%s%s[%s]%s'`, multiMark, option, quoteDescription(f.Usage), extras)
|
||||
}
|
||||
|
||||
func genFlagEntryForMultiOptionFlag(f *pflag.Flag) string {
|
||||
@ -154,7 +154,7 @@ func genFlagEntryForMultiOptionFlag(f *pflag.Flag) string {
|
||||
parenMultiMark, f.Shorthand, parenMultiMark, f.Name, curlyMultiMark, f.Shorthand, curlyMultiMark, f.Name)
|
||||
extras = genZshFlagEntryExtras(f)
|
||||
|
||||
return fmt.Sprintf(`%s'[%s]%s'`, options, f.Usage, extras)
|
||||
return fmt.Sprintf(`%s'[%s]%s'`, options, quoteDescription(f.Usage), extras)
|
||||
}
|
||||
|
||||
func genZshFlagEntryExtras(f *pflag.Flag) string {
|
||||
@ -177,3 +177,7 @@ func flagCouldBeSpecifiedMoreThenOnce(f *pflag.Flag) bool {
|
||||
return strings.Contains(f.Value.Type(), "Slice") ||
|
||||
strings.Contains(f.Value.Type(), "Array")
|
||||
}
|
||||
|
||||
func quoteDescription(s string) string {
|
||||
return strings.Replace(s, "'", `'\''`, -1)
|
||||
}
|
||||
|
Reference in New Issue
Block a user