scriptCommand method
The command line that prints the completion script for this shell:
<exe> completion --shell <shell>, or <exe> --completion <shell> if
viaOption. With a commandName, the completion command's
--command <name> option is added.
An executableName or commandName that is not a plain word, such as
a path with a space, is quoted for this shell.
Implementation
String scriptCommand(
final String executableName, {
final bool viaOption = false,
final String? commandName,
}) {
final isPowerShell = this == CompletionShell.powershell;
final word = isPowerShell ? powershellWord : shellWord;
final quotedExecutable = word(executableName);
// PowerShell runs a quoted command name only with the call operator.
final executable = isPowerShell && quotedExecutable != executableName
? '& $quotedExecutable'
: quotedExecutable;
final command = viaOption ? '--completion' : 'completion --shell';
final forCommand = commandName == null || viaOption
? ''
: ' --command ${word(commandName)}';
return '$executable $command $name$forCommand';
}