Skip to content

Commit

Permalink
[add] handling when fpm.rsp is empty for zsh.
Browse files Browse the repository at this point in the history
  • Loading branch information
ShinobuAmasaki committed Jan 22, 2024
1 parent 3540464 commit be80ee6
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions zsh/_fpm
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ build_dir_analysis() {
fi

for element in "${executables[@]}"; do
echo "$(basename $element)"
basename "$element"
done

}
Expand All @@ -122,21 +122,22 @@ build_dir_analysis_test() {

local -a tests
for dir in "${test_dir[@]}"; do
tests=( $(find "$dir" -type f -executable) "${tests[@]}" )
tests+=( $(find "$dir" -type f -executable) )
done

if [[ -z "${tests[*]}" ]]; then
return
fi

for element in "${tests[@]}"; do
echo $(basename $element)
basename "$element"
done

}

build_dir_analysis_example() {
local proj_dir=$(find_manifest_dir)
local proj_dir
proj_dir=$(find_manifest_dir)

if [ $? -eq 1 ]; then
return 1
Expand All @@ -161,7 +162,7 @@ build_dir_analysis_example() {
fi

for element in "${expls[@]}"; do
echo $(basename "$element" )
basename "$element"
done

}
Expand Down Expand Up @@ -214,7 +215,7 @@ _fpm_build() {
_values 'profiles' $profs
;;
(list)
if [[ "$word[*]" != *--tests* ]]; then
if [[ "${words[*]}" != *--tests* ]]; then
_message "--list option can only be specified together with --test option"
_values 'list' '--tests'
fi
Expand Down Expand Up @@ -290,22 +291,24 @@ _fpm_run() {
if [[ "${words[CURRENT]}" =~ '^@' ]]; then
local -a user_cmds
user_cmds=($(grep "^@" ./fpm.rsp 2>/dev/null | cut -c 1-))
_values 'commands' $user_cmds
if [[ -n "${user_cmds[*]}" ]]; then
_values 'commands' $user_cmds
fi
return
fi

_message "List of application names to execute."
local -a targets
targets=($(build_dir_analysis))
if [[ -n "$targets[*]" ]]; then
if [[ -n "${targets[*]}" ]]; then
_values 'target' $targets
fi
;;
(example)
_message "List of application names to execute."
local -a targets
targets=($(build_dir_analysis_example))
if [[ -n "$targets[*]" ]]; then
if [[ -n "${targets[*]}" ]]; then
_values 'target' $targets
fi
;;
Expand Down Expand Up @@ -398,7 +401,7 @@ _fpm_test() {
_message "List of application names to execute."
local -a targets
targets=($(build_dir_analysis_test))
if [[ -n "$targets[*]" ]]; then
if [[ -n "${targets[*]}" ]]; then
_values 'target' $targets
fi
;;
Expand Down Expand Up @@ -530,7 +533,7 @@ _fpm() {
_values 'commands' $commands
;;
(args)
case "$line[1]" in
case "${line[1]}" in
(new)
_fpm_new
;;
Expand Down

0 comments on commit be80ee6

Please # to comment.