Skip to content

Commit ab18468

Browse files
committed
update expose behavior to only show on --help
1 parent 7bd5203 commit ab18468

File tree

4 files changed

+37
-20
lines changed

4 files changed

+37
-20
lines changed

lib/bashly/script/command.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,14 @@ def command_help_data
7777

7878
public_commands.each do |command|
7979
result[command.group_string] ||= {}
80-
result[command.group_string][command.name] = command.summary_string
80+
result[command.group_string][command.name] = { summary: command.summary_string }
8181
next unless command.expose
8282

8383
command.public_commands.each do |subcommand|
84-
result[command.group_string]["#{command.name} #{subcommand.name}"] = subcommand.summary_string
84+
result[command.group_string]["#{command.name} #{subcommand.name}"] = {
85+
summary: subcommand.summary_string,
86+
extended: true
87+
}
8588
end
8689
end
8790

lib/bashly/views/command/usage_commands.erb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22
% maxlen = command_help_data.values.map(&:keys).flatten.map(&:size).max
33
% command_help_data.each do |group, commands|
44
printf "<%= group %>\n"
5-
% commands.each do |command, summary|
6-
echo " <%= command.ljust maxlen %> <%= summary %>"
5+
% commands.each do |command, info|
6+
% if info[:extended]
7+
[[ -n $long_usage ]] && echo " <%= command.ljust maxlen %> <%= info[:summary] %>"
8+
% else
9+
echo " <%= command.ljust maxlen %> <%= info[:summary] %>"
10+
% end
711
% end
812
echo
913
% end

spec/approvals/examples/commands-expose

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,10 @@ Usage:
2121
Commands:
2222
init Start a new project
2323
config Config management commands
24-
config edit Edit config file
25-
config show Show config file
2624

2725
Cluster Commands:
2826
server Server management commands
29-
server start Start the server
30-
server stop Stop the server
3127
container Container management commands
32-
container exec Run a command in the container
33-
container down Terminate a container
3428

3529
+ ./cli -h
3630
cli
Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,29 @@
11
---
22
'Commands:':
3-
init: Start a new project
4-
config: Config management commands
5-
config edit: Edit config file
6-
config show: Show config file
3+
init:
4+
:summary: Start a new project
5+
config:
6+
:summary: Config management commands
7+
config edit:
8+
:summary: Edit config file
9+
:extended: true
10+
config show:
11+
:summary: Show config file
12+
:extended: true
713
'Cluster Commands:':
8-
server: Server management commands
9-
server start: Start the server
10-
server stop: Stop the server
11-
container: Container management commands
12-
container exec: Run a command in the container
13-
container down: Terminate a container
14+
server:
15+
:summary: Server management commands
16+
server start:
17+
:summary: Start the server
18+
:extended: true
19+
server stop:
20+
:summary: Stop the server
21+
:extended: true
22+
container:
23+
:summary: Container management commands
24+
container exec:
25+
:summary: Run a command in the container
26+
:extended: true
27+
container down:
28+
:summary: Terminate a container
29+
:extended: true

0 commit comments

Comments
 (0)