Skip to content

Commit

Permalink
Merge pull request #578 from DannyBen/fix/other-args-shellcheck
Browse files Browse the repository at this point in the history
Remove `other_args` declaration if it is no used
  • Loading branch information
DannyBen authored Dec 20, 2024
2 parents 16568b7 + 82fe069 commit 786d8db
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
5 changes: 5 additions & 0 deletions lib/bashly/script/introspection/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ module Bashly
module Script
module Introspection
module Commands
# Returns true if the command or any of its descendants has `catch_all`
def catch_all_used_anywhere?
deep_commands(include_self: true).any? { |x| x.catch_all.enabled? }
end

# Returns a full list of the Command names and aliases combined
def command_aliases
commands.map(&:aliases).flatten
Expand Down
5 changes: 5 additions & 0 deletions lib/bashly/views/command/inspect_args.gtx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
> echo args: none
> fi
>

if catch_all_used_anywhere?
> if ((${#other_args[@]})); then
> echo
> echo other_args:
Expand All @@ -20,6 +22,8 @@
> done
> fi
>
end

if Settings.enabled? :deps_array
> if ((${#deps[@]})); then
> readarray -t sorted_keys < <(printf '%s\n' "${!deps[@]}" | sort)
Expand All @@ -31,6 +35,7 @@ if Settings.enabled? :deps_array
> fi
>
end

if Settings.enabled? :env_var_names_array
> if ((${#env_var_names[@]})); then
> readarray -t sorted_names < <(printf '%s\n' "${env_var_names[@]}" | sort)
Expand Down
13 changes: 11 additions & 2 deletions lib/bashly/views/command/run.gtx
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,34 @@

> run() {
> declare -g -A args=()

if catch_all_used_anywhere?
> declare -g -a other_args=()
end

if Settings.enabled? :deps_array
> declare -g -A deps=()
end
> declare -g -a other_args=()

if Settings.enabled? :env_var_names_array
> declare -g -a env_var_names=()
end

> declare -g -a input=()

if has_unique_args_or_flags?
> declare -g -A unique_lookup=()
end

> normalize_input "$@"
> parse_requirements "${input[@]}"

if user_file_exist?('before')
> before_hook
end

>
> case "$action" in

deep_commands.each do |command|
> "{{ command.action_name }}") {{ command.function_name }}_command ;;
end
Expand Down

0 comments on commit 786d8db

Please sign in to comment.