@@ -9,14 +9,26 @@ class CLI
99 # @since 0.1.0
1010 # @api private
1111 module Banner
12- # Prints command banner
12+ # Prints command/namespace banner
1313 #
14- # @param command [Dry::CLI::Command] the command
14+ # @param command [Dry::CLI::Command, Dry::CLI::Namespace ] the command/namespace
1515 # @param out [IO] standard output
1616 #
1717 # @since 0.1.0
1818 # @api private
1919 def self . call ( command , name )
20+ b = if CLI . command? ( command )
21+ command_banner ( command , name )
22+ else
23+ namespace_banner ( command , name )
24+ end
25+
26+ b . compact . join ( "\n " )
27+ end
28+
29+ # @since 1.1.1
30+ # @api private
31+ def self . command_banner ( command , name )
2032 [
2133 command_name ( name ) ,
2234 command_name_and_arguments ( command , name ) ,
@@ -25,13 +37,25 @@ def self.call(command, name)
2537 command_arguments ( command ) ,
2638 command_options ( command ) ,
2739 command_examples ( command , name )
28- ] . compact . join ( "\n " )
40+ ]
41+ end
42+
43+ # @since 1.1.1
44+ # @api private
45+ def self . namespace_banner ( namespace , name )
46+ [
47+ command_name ( name , "Namespace" ) ,
48+ command_name_and_arguments ( namespace , name ) ,
49+ command_description ( namespace ) ,
50+ command_subcommands ( namespace , "Commands" ) ,
51+ command_options ( namespace )
52+ ]
2953 end
3054
3155 # @since 0.1.0
3256 # @api private
33- def self . command_name ( name )
34- "Command :\n #{ name } "
57+ def self . command_name ( name , label = "Command" )
58+ "#{ label } :\n #{ name } "
3559 end
3660
3761 # @since 0.1.0
@@ -70,10 +94,10 @@ def self.command_description(command)
7094 "\n Description:\n #{ command . description } "
7195 end
7296
73- def self . command_subcommands ( command )
97+ def self . command_subcommands ( command , label = "Subcommands" )
7498 return if command . subcommands . empty?
7599
76- "\n Subcommands :\n #{ build_subcommands_list ( command . subcommands ) } "
100+ "\n #{ label } :\n #{ build_subcommands_list ( command . subcommands ) } "
77101 end
78102
79103 # @since 0.1.0
0 commit comments