installInstructions method

String installInstructions(
  1. String executableName, {
  2. bool viaOption = false,
  3. String? commandName,
})

Longer installation instructions for this shell, including alternative ways to install the script where available, and how to activate the installed completion (activationInstruction).

Implementation

String installInstructions(
  final String executableName, {
  final bool viaOption = false,
  final String? commandName,
}) {
  final name = commandName ?? executableName;
  final script = scriptCommand(
    executableName,
    viaOption: viaOption,
    commandName: commandName,
  );
  final command = installCommand(
    executableName,
    viaOption: viaOption,
    commandName: commandName,
  );
  final install = switch (this) {
    CompletionShell.bash =>
      'Add to ~/.bashrc:\n'
          '  $command\n'
          'or save it once:\n'
          '  $script > /etc/bash_completion.d/$name',
    CompletionShell.zsh =>
      'Add to ~/.zshrc (after compinit):\n'
          '  $command\n'
          'or save it once to a directory in \$fpath '
          '(then remove ~/.zcompdump* to rebuild the completion cache):\n'
          '  $script > "\${fpath[1]}/_$name"',
    CompletionShell.fish => 'Save it once:\n  $command',
    CompletionShell.powershell =>
      'Add to your PowerShell profile (\$PROFILE):\n  $command',
    CompletionShell.carapace =>
      'Save it once to the Carapace specs directory '
          '(shown by `carapace --help`):\n'
          '  $command\n'
          '(macOS: ~/Library/Application Support/carapace/specs/$name.yaml)',
  };
  return '$install\n$activationInstruction';
}