| 88 | } |
| 89 | |
| 90 | TOpt MakeCompletionOpt(const TOpts* opts, TString command, TString name) { |
| 91 | return TOpt() |
| 92 | .AddLongName(name) |
| 93 | .Help("generate tab completion script for zsh or bash") |
| 94 | .CompletionHelp("generate tab completion script") |
| 95 | .OptionalArgument("shell-syntax") |
| 96 | .CompletionArgHelp("shell syntax for completion script") |
| 97 | .IfPresentDisableCompletion() |
| 98 | .Completer(ShellChoiceCompleter()) |
| 99 | .Handler1T<TString>([opts, command, name](TStringBuf shell) { |
| 100 | if (shell.empty()) { |
| 101 | Cerr << Wrap(80, MakeInfo(command, "--" + name)) << Endl; |
| 102 | } else if (shell == "bash") { |
| 103 | TBashCompletionGenerator(opts).Generate(command, Cout); |
| 104 | } else if (shell == "zsh") { |
| 105 | TZshCompletionGenerator(opts).Generate(command, Cout); |
| 106 | } else { |
| 107 | Cerr << "Unknown shell name " << TString{shell}.Quote() << Endl; |
| 108 | exit(1); |
| 109 | } |
| 110 | exit(0); |
| 111 | }); |
| 112 | } |
| 113 | |
| 114 | class TCompleterMode: public TMainClassArgs { |
| 115 | public: |
no test coverage detected