File tree 3 files changed +42
-1
lines changed
3 files changed +42
-1
lines changed Original file line number Diff line number Diff line change @@ -185,7 +185,8 @@ class InitCommand extends Ahc\Cli\Input\Command
185
185
'<bold > init</end > <comment >--apple applet --ball ballon <arggg ></end > ## details 1<eol />' .
186
186
// $0 will be interpolated to actual command name
187
187
'<bold > $0</end > <comment >-a applet -b ballon <arggg > [arg2]</end > ## details 2<eol />'
188
- );
188
+ )
189
+ ->logo('Ascii art logo of your command');
189
190
}
190
191
191
192
// This method is auto called before `self::execute()` and receives `Interactor $io` instance
Original file line number Diff line number Diff line change @@ -52,6 +52,8 @@ class Command extends Parser implements Groupable
52
52
53
53
protected ?string $ _alias = null ;
54
54
55
+ protected string $ _logo = '' ;
56
+
55
57
protected string $ _help = '' ;
56
58
57
59
private array $ _events = [];
@@ -154,6 +156,24 @@ public function bind(?App $app = null): self
154
156
return $ this ;
155
157
}
156
158
159
+ /**
160
+ * Sets or gets the ASCII art logo.
161
+ *
162
+ * @param string|null $logo
163
+ *
164
+ * @return string|self
165
+ */
166
+ public function logo (?string $ logo = null )
167
+ {
168
+ if (func_num_args () === 0 ) {
169
+ return $ this ->_logo ;
170
+ }
171
+
172
+ $ this ->_logo = $ logo ;
173
+
174
+ return $ this ;
175
+ }
176
+
157
177
/**
158
178
* Registers argument definitions (all at once). Only last one can be variadic.
159
179
*/
@@ -332,6 +352,11 @@ public function showDefaultHelp(): mixed
332
352
{
333
353
$ io = $ this ->io ();
334
354
$ helper = new OutputHelper ($ io ->writer ());
355
+ $ app = $ this ->app ();
356
+
357
+ if (($ logo = $ this ->logo ()) || ($ app && ($ logo = $ app ->logo ()) && $ app ->getDefaultCommand () === $ this ->_name )) {
358
+ $ io ->logo ($ logo , true );
359
+ }
335
360
336
361
$ io ->help_header ("Command {$ this ->_name }, version {$ this ->_version }" , true )->eol ();
337
362
$ io ->help_summary ($ this ->_desc , true )->eol ();
Original file line number Diff line number Diff line change @@ -237,6 +237,21 @@ public function test_logo()
237
237
$ this ->assertSame ($ logo , $ a ->logo ());
238
238
}
239
239
240
+ public function test_logo_command ()
241
+ {
242
+ $ a = $ this ->newApp ('test ' , '0.0.2 ' );
243
+ $ c = $ a ->command ('cmd ' );
244
+
245
+ $ this ->assertSame ($ c , $ c ->logo ($ logo = '
246
+ | |_ ___ ___| |_
247
+ | __/ _ \/ __| __|
248
+ | || __/\__ \ |_
249
+ \__\___||___/\__|
250
+ ' ));
251
+
252
+ $ this ->assertSame ($ logo , $ c ->logo ());
253
+ }
254
+
240
255
public function test_add ()
241
256
{
242
257
$ a = $ this ->newApp ('test ' , '0.0.1-test ' );
You can’t perform that action at this time.
0 commit comments