33namespace Stecman \Component \Symfony \Console \BashCompletion ;
44
55use Symfony \Component \Console \Command \Command as SymfonyCommand ;
6+ use Symfony \Component \Console \Input \InputDefinition ;
67use Symfony \Component \Console \Input \InputInterface ;
78use Symfony \Component \Console \Input \InputOption ;
89use Symfony \Component \Console \Output \OutputInterface ;
@@ -19,6 +20,7 @@ protected function configure()
1920 {
2021 $ this
2122 ->setName ('_completion ' )
23+ ->setDefinition ($ this ->createDefinition ())
2224 ->setDescription ('BASH completion hook. ' )
2325 ->setHelp (<<<END
2426To enable BASH completion, run:
@@ -30,27 +32,17 @@ protected function configure()
3032 <comment>eval `[program] _completion -g -p [alias]`</comment>.
3133
3234END
33- )
34- ->addOption (
35- 'generate-hook ' ,
36- 'g ' ,
37- InputOption::VALUE_NONE ,
38- 'Generate BASH code that sets up completion for this application. '
39- )
40- ->addOption (
41- 'program ' ,
42- 'p ' ,
43- InputOption::VALUE_REQUIRED ,
44- "Program name that should trigger completion \n<comment>(defaults to the absolute application path)</comment>. "
45- )
46- ->addOption (
47- 'shell-type ' ,
48- null ,
49- InputOption::VALUE_OPTIONAL ,
50- 'Set the shell type (zsh or bash). Otherwise this is determined automatically. '
5135 );
5236 }
5337
38+ /**
39+ * {@inheritdoc}
40+ */
41+ public function getNativeDefinition ()
42+ {
43+ return $ this ->createDefinition ();
44+ }
45+
5446 protected function execute (InputInterface $ input , OutputInterface $ output )
5547 {
5648 $ this ->handler = new CompletionHandler ($ this ->getApplication ());
@@ -110,4 +102,28 @@ protected function getShellType()
110102
111103 return basename (getenv ('SHELL ' ));
112104 }
105+
106+ protected function createDefinition ()
107+ {
108+ return new InputDefinition (array (
109+ new InputOption (
110+ 'generate-hook ' ,
111+ 'g ' ,
112+ InputOption::VALUE_NONE ,
113+ 'Generate BASH code that sets up completion for this application. '
114+ ),
115+ new InputOption (
116+ 'program ' ,
117+ 'p ' ,
118+ InputOption::VALUE_REQUIRED ,
119+ "Program name that should trigger completion \n<comment>(defaults to the absolute application path)</comment>. "
120+ ),
121+ new InputOption (
122+ 'shell-type ' ,
123+ null ,
124+ InputOption::VALUE_OPTIONAL ,
125+ 'Set the shell type (zsh or bash). Otherwise this is determined automatically. '
126+ ),
127+ ));
128+ }
113129}
0 commit comments