Skip to content

Commit 48f6cdd

Browse files
authored
Merge pull request #588 from DannyBen/change/globals-location
Move global var declarations from `run()` to `initialize()`
2 parents fd54157 + 9167c49 commit 48f6cdd

File tree

3 files changed

+31
-27
lines changed

3 files changed

+31
-27
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
= view_marker
2+
3+
> declare -g -A args=()
4+
5+
if catch_all_used_anywhere?
6+
> declare -g -a other_args=()
7+
end
8+
9+
if Settings.enabled? :deps_array
10+
> declare -g -A deps=()
11+
end
12+
13+
if Settings.enabled? :env_var_names_array
14+
> declare -g -a env_var_names=()
15+
end
16+
17+
> declare -g -a input=()
18+
19+
if has_unique_args_or_flags?
20+
> declare -g -A unique_lookup=()
21+
end
22+
23+
>
24+
Settings.var_aliases.each do |original, refname|
25+
if refname
26+
> declare -gn {{ refname }}={{ original }}
27+
end
28+
end
29+
>

lib/bashly/views/command/initialize.gtx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ if root_command?
1111
= render(:environment_variables_default).indent 2
1212
end
1313

14+
= render(:globals).indent(2)
15+
1416
if user_file_exist?('initialize')
1517
>
1618
= load_user_file('initialize').indent 2

lib/bashly/views/command/run.gtx

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,6 @@
11
= view_marker
22

33
> run() {
4-
> declare -g -A args=()
5-
6-
if catch_all_used_anywhere?
7-
> declare -g -a other_args=()
8-
end
9-
10-
if Settings.enabled? :deps_array
11-
> declare -g -A deps=()
12-
end
13-
14-
if Settings.enabled? :env_var_names_array
15-
> declare -g -a env_var_names=()
16-
end
17-
18-
> declare -g -a input=()
19-
20-
if has_unique_args_or_flags?
21-
> declare -g -A unique_lookup=()
22-
end
23-
24-
>
25-
Settings.var_aliases.each do |original, refname|
26-
if refname
27-
> declare -gn {{ refname }}={{ original }}
28-
end
29-
end
30-
>
314
> normalize_input "$@"
325
> parse_requirements "${input[@]}"
336

0 commit comments

Comments
 (0)