File tree Expand file tree Collapse file tree 3 files changed +42
-1
lines changed
Expand file tree Collapse file tree 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
185185 '<bold > init</end > <comment >--apple applet --ball ballon <arggg ></end > ## details 1<eol />' .
186186 // $0 will be interpolated to actual command name
187187 '<bold > $0</end > <comment >-a applet -b ballon <arggg > [arg2]</end > ## details 2<eol />'
188- );
188+ )
189+ ->logo('Ascii art logo of your command');
189190 }
190191
191192 // 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
5252
5353 protected ?string $ _alias = null ;
5454
55+ protected string $ _logo = '' ;
56+
5557 protected string $ _help = '' ;
5658
5759 private array $ _events = [];
@@ -154,6 +156,24 @@ public function bind(?App $app = null): self
154156 return $ this ;
155157 }
156158
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+
157177 /**
158178 * Registers argument definitions (all at once). Only last one can be variadic.
159179 */
@@ -332,6 +352,11 @@ public function showDefaultHelp(): mixed
332352 {
333353 $ io = $ this ->io ();
334354 $ 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+ }
335360
336361 $ io ->help_header ("Command {$ this ->_name }, version {$ this ->_version }" , true )->eol ();
337362 $ 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()
237237 $ this ->assertSame ($ logo , $ a ->logo ());
238238 }
239239
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+
240255 public function test_add ()
241256 {
242257 $ a = $ this ->newApp ('test ' , '0.0.1-test ' );
You can’t perform that action at this time.
0 commit comments