installCommand method
The command that installs the completion script for this shell,
e.g. source <(mycli completion --shell bash).
See installLocation for where to run or add it,
and scriptCommand for viaOption and commandName.
Implementation
String installCommand(
final String executableName, {
final bool viaOption = false,
final String? commandName,
}) {
final name = commandName ?? executableName;
final script = scriptCommand(
executableName,
viaOption: viaOption,
commandName: commandName,
);
return switch (this) {
CompletionShell.bash || CompletionShell.zsh => 'source <($script)',
CompletionShell.fish => '$script > ~/.config/fish/completions/$name.fish',
CompletionShell.powershell => '$script | Out-String | Invoke-Expression',
CompletionShell.carapace =>
'$script > ~/.config/carapace/specs/$name.yaml',
};
}