2e86c939
xu
“首次提交”
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
<?php
namespace Stecman\Component\Symfony\Console\BashCompletion;
use Stecman\Component\Symfony\Console\BashCompletion\Completion\CompletionInterface;
class Completion implements CompletionInterface
{
/**
* The type of input (option/argument) the completion should be run for
*
* @see CompletionInterface::ALL_TYPES
* @var string
*/
protected $type;
/**
* The command name the completion should be run for
*
* @see CompletionInterface::ALL_COMMANDS
* @var string|null
*/
protected $commandName;
/**
* The option/argument name the completion should be run for
*
* @var string
*/
protected $targetName;
/**
* Array of values to return, or a callback to generate completion results with
* The callback can be in any form accepted by call_user_func.
*
* @var callable|array
*/
protected $completion;
/**
* Create a Completion with the command name set to CompletionInterface::ALL_COMMANDS
*
* @deprecated - This will be removed in 1.0.0 as it is redundant and isn't any more concise than what it implements.
*
* @param string $targetName
* @param string $type
* @param array|callable $completion
* @return Completion
*/
public static function makeGlobalHandler($targetName, $type, $completion)
{
return new Completion(CompletionInterface::ALL_COMMANDS, $targetName, $type, $completion);
}
/**
* @param string $commandName
* @param string $targetName
* @param string $type
* @param array|callable $completion
*/
public function __construct($commandName, $targetName, $type, $completion)
{
$this->commandName = $commandName;
$this->targetName = $targetName;
$this->type = $type;
$this->completion = $completion;
}
/**
* Return the stored completion, or the results returned from the completion callback
*
* @return array
*/
public function run()
{
if ($this->isCallable()) {
return call_user_func($this->completion);
}
return $this->completion;
}
/**
* Get type of input (option/argument) the completion should be run for
*
* @see CompletionInterface::ALL_TYPES
* @return string|null
*/
public function getType()
{
return $this->type;
}
/**
* Set type of input (option/argument) the completion should be run for
*
* @see CompletionInterface::ALL_TYPES
* @param string|null $type
*/
public function setType($type)
{
$this->type = $type;
}
/**
* Get the command name the completion should be run for
*
* @see CompletionInterface::ALL_COMMANDS
* @return string|null
*/
public function getCommandName()
{
return $this->commandName;
}
/**
* Set the command name the completion should be run for
*
* @see CompletionInterface::ALL_COMMANDS
* @param string|null $commandName
*/
public function setCommandName($commandName)
{
$this->commandName = $commandName;
}
/**
* Set the option/argument name the completion should be run for
*
* @see setType()
* @return string
*/
public function getTargetName()
{
return $this->targetName;
}
/**
* Get the option/argument name the completion should be run for
*
* @see getType()
* @param string $targetName
*/
public function setTargetName($targetName)
{
$this->targetName = $targetName;
}
/**
* Return the array or callback configured for for the Completion
*
* @return array|callable
*/
public function getCompletion()
{
return $this->completion;
}
/**
* Set the array or callback to return/run when Completion is run
*
* @see run()
* @param array|callable $completion
*/
public function setCompletion($completion)
{
$this->completion = $completion;
}
/**
* Check if the configured completion value is a callback function
*
* @return bool
*/
public function isCallable()
{
return is_callable($this->completion);
}
}
|