Skip to content

Commit c35d057

Browse files
committed
minor template normalization
1 parent cd058d7 commit c35d057

File tree

6 files changed

+22
-17
lines changed

6 files changed

+22
-17
lines changed

lib/bashly/extensions/string.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ def sanitize_for_print
55

66
def indent(offset)
77
return self unless offset > 0
8-
split("\n").indent(offset).join("\n")
8+
lines.indent(offset).join
99
end
1010

1111
def to_underscore
@@ -24,7 +24,7 @@ def wrap(length = 80)
2424
end
2525

2626
def lint
27-
gsub(/\s+\n/m, "\n\n").lines.reject { |l| l =~ /^\s*##/ }.join ""
27+
gsub(/\s+\n/m, "\n\n").lines.reject { |l| l =~ /^\s*##/ }.join
2828
end
2929

3030
def remove_front_matter
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
= view_marker
2+
3+
> if [[ -n $long_usage ]]; then
4+
> printf "{{ strings[:options] }}\n"
5+
>
6+
= render(:usage_fixed_flags).indent 2
7+
= render(:usage_flags).indent 2 if flags.any?
8+
= render(:usage_args).indent 2 if args.any? or catch_all.help
9+
= render(:usage_environment_variables).indent 2 if environment_variables.any?
10+
= render(:usage_examples).indent 2 if examples
11+
= render(:footer).indent 2 if footer
12+
>
13+
> fi

lib/bashly/views/command/usage.gtx

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,7 @@ end
4040

4141
= render(:usage_commands).indent 2 if commands.any?
4242
>
43-
44-
> if [[ -n $long_usage ]]; then
45-
> printf "{{ strings[:options] }}\n"
46-
47-
= render(:usage_fixed_flags).indent 4
48-
= render(:usage_flags).indent 4 if flags.any?
49-
= render(:usage_args).indent 4 if args.any? or catch_all.help
50-
= render(:usage_environment_variables).indent 4 if environment_variables.any?
51-
= render(:usage_examples).indent 4 if examples
52-
= render(:footer).indent 4 if footer
53-
54-
>
55-
> fi
43+
= render(:long_usage).indent 2
5644
> }
5745
>
5846

lib/bashly/views/command/usage_args.gtx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ if catch_all.help
1515
> printf "{{ catch_all.help.wrap(76).indent(4).sanitize_for_print }}\n"
1616
> echo
1717
end
18+
19+
>
20+

lib/bashly/views/command/usage_environment_variables.gtx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@
66
environment_variables.each do |env_var|
77
= env_var.render :usage
88
end
9+
10+
>
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
= view_marker
22

33
> printf "{{ strings[:examples] }}\n"
4-
>
54

65
examples.each do |example|
76
> printf "{{ example.wrap(78).indent(2).sanitize_for_print }}\n"
87
end
98

109
> echo
11-
>
10+
>

0 commit comments

Comments
 (0)