bashly 0.8.1 → 0.8.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bashly/commands/generate.rb +40 -4
- data/lib/bashly/concerns/renderable.rb +19 -6
- data/lib/bashly/config_validator.rb +11 -0
- data/lib/bashly/extensions/string.rb +2 -2
- data/lib/bashly/script/command.rb +126 -24
- data/lib/bashly/templates/strings.yml +1 -0
- data/lib/bashly/version.rb +1 -1
- data/lib/bashly/views/README.md +6 -0
- data/lib/bashly/views/argument/usage.gtx +15 -0
- data/lib/bashly/views/argument/validations.gtx +11 -0
- data/lib/bashly/views/command/catch_all_filter.gtx +10 -0
- data/lib/bashly/views/command/command_fallback.gtx +42 -0
- data/lib/bashly/views/command/command_filter.gtx +29 -0
- data/lib/bashly/views/command/command_functions.gtx +5 -0
- data/lib/bashly/views/command/default_assignments.gtx +13 -0
- data/lib/bashly/views/command/default_initialize_script.gtx +7 -0
- data/lib/bashly/views/command/default_root_script.gtx +4 -0
- data/lib/bashly/views/command/default_script.gtx +5 -0
- data/lib/bashly/views/command/dependencies_filter.gtx +10 -0
- data/lib/bashly/views/command/environment_variables_filter.gtx +18 -0
- data/lib/bashly/views/command/fixed_flags_filter.gtx +20 -0
- data/lib/bashly/views/command/footer.gtx +5 -0
- data/lib/bashly/views/command/function.gtx +6 -0
- data/lib/bashly/views/command/initialize.gtx +12 -0
- data/lib/bashly/views/command/inspect_args.gtx +21 -0
- data/lib/bashly/views/command/long_usage.gtx +13 -0
- data/lib/bashly/views/command/master_script.gtx +17 -0
- data/lib/bashly/views/command/normalize_input.gtx +25 -0
- data/lib/bashly/views/command/parse_requirements.gtx +26 -0
- data/lib/bashly/views/command/parse_requirements_case.gtx +11 -0
- data/lib/bashly/views/command/parse_requirements_case_catch_all.gtx +23 -0
- data/lib/bashly/views/command/parse_requirements_case_repeatable.gtx +24 -0
- data/lib/bashly/views/command/parse_requirements_case_simple.gtx +25 -0
- data/lib/bashly/views/command/parse_requirements_while.gtx +33 -0
- data/lib/bashly/views/command/required_args_filter.gtx +13 -0
- data/lib/bashly/views/command/required_flags_filter.gtx +12 -0
- data/lib/bashly/views/command/root_command.gtx +6 -0
- data/lib/bashly/views/command/run.gtx +28 -0
- data/lib/bashly/views/command/usage.gtx +50 -0
- data/lib/bashly/views/command/usage_args.gtx +20 -0
- data/lib/bashly/views/command/usage_commands.gtx +18 -0
- data/lib/bashly/views/command/usage_environment_variables.gtx +10 -0
- data/lib/bashly/views/command/usage_examples.gtx +10 -0
- data/lib/bashly/views/command/usage_fixed_flags.gtx +13 -0
- data/lib/bashly/views/command/usage_flags.gtx +7 -0
- data/lib/bashly/views/command/user_filter.gtx +13 -0
- data/lib/bashly/views/command/user_lib.gtx +11 -0
- data/lib/bashly/views/command/version_command.gtx +6 -0
- data/lib/bashly/views/command/whitelist_filter.gtx +41 -0
- data/lib/bashly/views/environment_variable/usage.gtx +11 -0
- data/lib/bashly/views/flag/case.gtx +6 -0
- data/lib/bashly/views/flag/case_arg.gtx +25 -0
- data/lib/bashly/views/flag/case_no_arg.gtx +11 -0
- data/lib/bashly/views/flag/conflicts.gtx +22 -0
- data/lib/bashly/views/flag/usage.gtx +15 -0
- data/lib/bashly/views/flag/validations.gtx +11 -0
- data/lib/bashly/views/wrapper/bash3_bouncer.gtx +7 -0
- data/lib/bashly/views/wrapper/header.gtx +5 -0
- data/lib/bashly/views/wrapper/wrapper.gtx +8 -0
- metadata +89 -60
- data/lib/bashly/concerns/command_scopes.rb +0 -83
- data/lib/bashly/views/argument/usage.erb +0 -10
- data/lib/bashly/views/argument/validations.erb +0 -8
- data/lib/bashly/views/command/catch_all_filter.erb +0 -7
- data/lib/bashly/views/command/command_fallback.erb +0 -45
- data/lib/bashly/views/command/command_filter.erb +0 -22
- data/lib/bashly/views/command/command_functions.erb +0 -4
- data/lib/bashly/views/command/default_assignments.erb +0 -7
- data/lib/bashly/views/command/default_initialize_script.erb +0 -6
- data/lib/bashly/views/command/default_root_script.erb +0 -3
- data/lib/bashly/views/command/default_script.erb +0 -4
- data/lib/bashly/views/command/dependencies_filter.erb +0 -9
- data/lib/bashly/views/command/environment_variables_filter.erb +0 -14
- data/lib/bashly/views/command/fixed_flags_filter.erb +0 -24
- data/lib/bashly/views/command/footer.erb +0 -3
- data/lib/bashly/views/command/function.erb +0 -4
- data/lib/bashly/views/command/initialize.erb +0 -8
- data/lib/bashly/views/command/inspect_args.erb +0 -19
- data/lib/bashly/views/command/master_script.erb +0 -14
- data/lib/bashly/views/command/normalize_input.erb +0 -24
- data/lib/bashly/views/command/parse_requirements.erb +0 -22
- data/lib/bashly/views/command/parse_requirements_case.erb +0 -8
- data/lib/bashly/views/command/parse_requirements_case_catch_all.erb +0 -18
- data/lib/bashly/views/command/parse_requirements_case_repeatable.erb +0 -18
- data/lib/bashly/views/command/parse_requirements_case_simple.erb +0 -18
- data/lib/bashly/views/command/parse_requirements_while.erb +0 -26
- data/lib/bashly/views/command/required_args_filter.erb +0 -7
- data/lib/bashly/views/command/required_flags_filter.erb +0 -7
- data/lib/bashly/views/command/root_command.erb +0 -4
- data/lib/bashly/views/command/run.erb +0 -23
- data/lib/bashly/views/command/usage.erb +0 -50
- data/lib/bashly/views/command/usage_args.erb +0 -14
- data/lib/bashly/views/command/usage_commands.erb +0 -18
- data/lib/bashly/views/command/usage_environment_variables.erb +0 -6
- data/lib/bashly/views/command/usage_examples.erb +0 -7
- data/lib/bashly/views/command/usage_fixed_flags.erb +0 -17
- data/lib/bashly/views/command/usage_flags.erb +0 -4
- data/lib/bashly/views/command/user_filter.erb +0 -11
- data/lib/bashly/views/command/user_lib.erb +0 -6
- data/lib/bashly/views/command/version_command.erb +0 -4
- data/lib/bashly/views/command/whitelist_filter.erb +0 -33
- data/lib/bashly/views/environment_variable/usage.erb +0 -7
- data/lib/bashly/views/flag/case.erb +0 -4
- data/lib/bashly/views/flag/case_arg.erb +0 -19
- data/lib/bashly/views/flag/case_no_arg.erb +0 -8
- data/lib/bashly/views/flag/conflicts.erb +0 -18
- data/lib/bashly/views/flag/usage.erb +0 -10
- data/lib/bashly/views/flag/validations.erb +0 -8
- data/lib/bashly/views/wrapper/bash3_bouncer.erb +0 -5
- data/lib/bashly/views/wrapper/header.erb +0 -4
- data/lib/bashly/views/wrapper/wrapper.erb +0 -6
@@ -1,26 +0,0 @@
|
|
1
|
-
<%= view_marker %>
|
2
|
-
while [[ $# -gt 0 ]]; do
|
3
|
-
key="$1"
|
4
|
-
case "$key" in
|
5
|
-
% flags.each do |flag|
|
6
|
-
<%= flag.render(:case).indent 2 %>
|
7
|
-
|
8
|
-
% end
|
9
|
-
|
10
|
-
-?* )
|
11
|
-
% if catch_all.enabled?
|
12
|
-
other_args+=("$1")
|
13
|
-
shift
|
14
|
-
;;
|
15
|
-
% else
|
16
|
-
printf "<%= strings[:invalid_flag] %>\n" "$key"
|
17
|
-
exit 1
|
18
|
-
;;
|
19
|
-
% end
|
20
|
-
|
21
|
-
* )
|
22
|
-
<%= render(:parse_requirements_case).indent 4 %>
|
23
|
-
;;
|
24
|
-
|
25
|
-
esac
|
26
|
-
done
|
@@ -1,23 +0,0 @@
|
|
1
|
-
<%= view_marker %>
|
2
|
-
run() {
|
3
|
-
declare -A args=()
|
4
|
-
declare -a other_args=()
|
5
|
-
declare -a input=()
|
6
|
-
normalize_input "$@"
|
7
|
-
parse_requirements "${input[@]}"
|
8
|
-
|
9
|
-
<%- condition = "if" -%>
|
10
|
-
<%- deep_commands.each do |command| -%>
|
11
|
-
<%= condition %> [[ $action == "<%= command.action_name %>" ]]; then
|
12
|
-
if [[ ${args[--help]:-} ]]; then
|
13
|
-
long_usage=yes
|
14
|
-
<%= command.function_name %>_usage
|
15
|
-
else
|
16
|
-
<%= command.function_name %>_command
|
17
|
-
fi
|
18
|
-
<% condition = "elif" %>
|
19
|
-
<%- end -%>
|
20
|
-
<%= condition %> [[ $action == "root" ]]; then
|
21
|
-
root_command
|
22
|
-
fi
|
23
|
-
}
|
@@ -1,50 +0,0 @@
|
|
1
|
-
<%= view_marker %>
|
2
|
-
<%= function_name %>_usage() {
|
3
|
-
if [[ -n $long_usage ]]; then
|
4
|
-
<%- if summary == help -%>
|
5
|
-
printf "<%= caption_string %>\n"
|
6
|
-
echo
|
7
|
-
<%- else -%>
|
8
|
-
printf "<%= full_name %>\n"
|
9
|
-
echo
|
10
|
-
printf "<%= help.wrap(78).indent(2).sanitize_for_print %>\n"
|
11
|
-
echo
|
12
|
-
<%- end -%>
|
13
|
-
else
|
14
|
-
printf "<%= caption_string %>\n"
|
15
|
-
echo
|
16
|
-
fi
|
17
|
-
|
18
|
-
<%- if alt&.any? -%>
|
19
|
-
printf "<%= strings[:command_alias] % { alias: alt.join(', ') } %>\n"
|
20
|
-
echo
|
21
|
-
<%- end -%>
|
22
|
-
|
23
|
-
printf "<%= strings[:usage] %>\n"
|
24
|
-
printf " <%= usage_string %>\n"
|
25
|
-
<%- if commands.any? -%>
|
26
|
-
printf " <%= full_name %> [command] --help<%= " | -h" unless short_flag_exist? "-h" -%>\n"
|
27
|
-
<%- else -%>
|
28
|
-
printf " <%= full_name %> --help<%= " | -h" unless short_flag_exist? "-h" -%>\n"
|
29
|
-
<%- end -%>
|
30
|
-
<%- if root_command? -%>
|
31
|
-
printf " <%= full_name %> --version<%= " | -v" unless short_flag_exist? "-v" -%>\n"
|
32
|
-
<%- end -%>
|
33
|
-
echo
|
34
|
-
<%= render(:usage_commands).indent 2 if commands.any? %>
|
35
|
-
|
36
|
-
if [[ -n $long_usage ]]; then
|
37
|
-
printf "<%= strings[:options] %>\n"
|
38
|
-
<%= render(:usage_fixed_flags).indent 4 %>
|
39
|
-
<%= render(:usage_flags).indent 4 if flags.any? %>
|
40
|
-
<%= render(:usage_args).indent 4 if args.any? or catch_all.help %>
|
41
|
-
<%= render(:usage_environment_variables).indent 4 if environment_variables.any? %>
|
42
|
-
<%= render(:usage_examples).indent 4 if examples %>
|
43
|
-
<%= render(:footer).indent 4 if footer %>
|
44
|
-
|
45
|
-
fi
|
46
|
-
}
|
47
|
-
|
48
|
-
<%- commands.each do |command| -%>
|
49
|
-
<%= command.render 'usage' %>
|
50
|
-
<%- end -%>
|
@@ -1,14 +0,0 @@
|
|
1
|
-
<%= view_marker %>
|
2
|
-
printf "<%= strings[:arguments] %>\n"
|
3
|
-
% if args.any?
|
4
|
-
|
5
|
-
% args.each do |arg|
|
6
|
-
<%= arg.render(:usage) %>
|
7
|
-
% end
|
8
|
-
% end
|
9
|
-
% if catch_all.help
|
10
|
-
|
11
|
-
echo " <%= catch_all.label %>"
|
12
|
-
printf "<%= catch_all.help.wrap(76).indent(4).sanitize_for_print %>\n"
|
13
|
-
echo
|
14
|
-
% end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
<%= view_marker %>
|
2
|
-
% unless commands.first.group
|
3
|
-
printf "<%= strings[:commands] %>\n"
|
4
|
-
% end
|
5
|
-
% maxlen = command_names.map(&:size).max
|
6
|
-
% commands.reject(&:private).each do |command|
|
7
|
-
% summary = command.summary
|
8
|
-
% summary = strings[:default_command_summary] % { summary: summary } if command.default
|
9
|
-
% if command.group
|
10
|
-
% if command.name == commands.first.name
|
11
|
-
printf "<%= strings[:group] % { group: command.group } %>\n"
|
12
|
-
% else
|
13
|
-
printf "\n<%= strings[:group] % { group: command.group } %>\n"
|
14
|
-
% end
|
15
|
-
% end
|
16
|
-
echo " <%= command.name.ljust maxlen %> <%= summary %>"
|
17
|
-
% end
|
18
|
-
echo
|
@@ -1,17 +0,0 @@
|
|
1
|
-
<%= view_marker %>
|
2
|
-
% if short_flag_exist? "-h"
|
3
|
-
echo " --help"
|
4
|
-
% else
|
5
|
-
echo " --help, -h"
|
6
|
-
% end
|
7
|
-
printf " <%= strings[:help_flag_text] %>\n"
|
8
|
-
echo
|
9
|
-
% if root_command?
|
10
|
-
% if short_flag_exist? "-v"
|
11
|
-
echo " --version"
|
12
|
-
% else
|
13
|
-
echo " --version, -v"
|
14
|
-
% end
|
15
|
-
printf " <%= strings[:version_flag_text] %>\n"
|
16
|
-
echo
|
17
|
-
% end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
<%= view_marker %>
|
2
|
-
% whitelisted_args.each do |arg|
|
3
|
-
% if arg.repeatable
|
4
|
-
eval "input_array=(${args[<%= arg.name %>]})"
|
5
|
-
for i in "${input_array[@]}"; do
|
6
|
-
if [[ ! $i =~ ^(<%= arg.allowed.join '|' %>)$ ]]; then
|
7
|
-
printf "%s\n" "<%= strings[:disallowed_argument] % { name: arg.name, allowed: arg.allowed.join(', ') } %>"
|
8
|
-
exit 1
|
9
|
-
fi
|
10
|
-
done
|
11
|
-
% else
|
12
|
-
if [[ ! ${args[<%= arg.name %>]} =~ ^(<%= arg.allowed.join '|' %>)$ ]]; then
|
13
|
-
printf "%s\n" "<%= strings[:disallowed_argument] % { name: arg.name, allowed: arg.allowed.join(', ') } %>"
|
14
|
-
exit 1
|
15
|
-
fi
|
16
|
-
% end
|
17
|
-
% end
|
18
|
-
% whitelisted_flags.each do |flag|
|
19
|
-
% if flag.repeatable
|
20
|
-
eval "input_array=(${args[<%= flag.name %>]})"
|
21
|
-
for i in "${input_array[@]}"; do
|
22
|
-
if [[ ! $i =~ ^(<%= flag.allowed.join '|' %>)$ ]]; then
|
23
|
-
printf "%s\n" "<%= strings[:disallowed_flag] % { name: flag.name, allowed: flag.allowed.join(', ') } %>"
|
24
|
-
exit 1
|
25
|
-
fi
|
26
|
-
done
|
27
|
-
% else
|
28
|
-
if [[ ! ${args[<%= flag.name %>]} =~ ^(<%= flag.allowed.join '|' %>)$ ]]; then
|
29
|
-
printf "%s\n" "<%= strings[:disallowed_flag] % { name: flag.name, allowed: flag.allowed.join(', ') } %>"
|
30
|
-
exit 1
|
31
|
-
fi
|
32
|
-
% end
|
33
|
-
% end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
<%= view_marker %>
|
2
|
-
if [[ -n ${2+x} ]]; then
|
3
|
-
<%= render(:validations).indent 2 %>
|
4
|
-
% if repeatable
|
5
|
-
if [[ -z ${args[<%= name %>]+x} ]]; then
|
6
|
-
args[<%= name %>]="\"$2\""
|
7
|
-
else
|
8
|
-
args[<%= name %>]="${args[<%= name %>]} \"$2\""
|
9
|
-
fi
|
10
|
-
% else
|
11
|
-
args[<%= name %>]="$2"
|
12
|
-
% end
|
13
|
-
shift
|
14
|
-
shift
|
15
|
-
else
|
16
|
-
printf "%s\n" "<%= strings[:flag_requires_an_argument] % { name: name, usage: usage_string } %>"
|
17
|
-
exit 1
|
18
|
-
fi
|
19
|
-
;;
|
@@ -1,18 +0,0 @@
|
|
1
|
-
<%= view_marker %>
|
2
|
-
% if conflicts
|
3
|
-
% if conflicts.count == 1
|
4
|
-
if [[ -n "${args[<%= conflicts.first %>]:-}" ]]; then
|
5
|
-
printf "<%= strings[:conflicting_flags] %>\n" "$key" "<%= conflicts.first %>"
|
6
|
-
exit 1
|
7
|
-
fi
|
8
|
-
|
9
|
-
% else
|
10
|
-
for conflict in <%= conflicts.join ' ' %>; do
|
11
|
-
if [[ -n "${args[$conflict]:-}" ]]; then
|
12
|
-
printf "<%= strings[:conflicting_flags] %>\n" "$key" "$conflict"
|
13
|
-
exit 1
|
14
|
-
fi
|
15
|
-
done
|
16
|
-
|
17
|
-
% end
|
18
|
-
% end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
<%= view_marker %>
|
2
|
-
echo " <%= usage_string extended: true %>"
|
3
|
-
printf "<%= help.wrap(76).indent(4).sanitize_for_print %>\n"
|
4
|
-
% if allowed
|
5
|
-
printf " <%= strings[:allowed] % { values: allowed.join(', ') } -%>\n"
|
6
|
-
% end
|
7
|
-
% if default
|
8
|
-
printf " <%= strings[:default] % { value: default } -%>\n"
|
9
|
-
% end
|
10
|
-
echo
|