Skip to content

Commit

Permalink
Fix incorrect argument completion
Browse files Browse the repository at this point in the history
  • Loading branch information
mayuki committed May 28, 2020
1 parent d320fcb commit 427b40d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private void WriteCommandDefineOptionAndArguments(TextWriter writer, CommandDesc
}
foreach (var arg in command.Arguments)
{
writer.WriteLine($" __cocona_{_appName}_completion_define_argument \"--{arg.Name}\" \"{FromArgumentToCandidatesType(arg)}\"");
writer.WriteLine($" __cocona_{_appName}_completion_define_argument \"{arg.Name}\" \"{FromArgumentToCandidatesType(arg)}\"");
}

string FromOptionToCandidatesType(ICommandOptionDescriptor option)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,14 @@ __cocona_APPNAMEPLACEHOLDER_completion_get_argument_index() {
local index=0
local options_completed=0
local prev_is_option=0
local current_pos="$1"

for param in "${params[@]}"
do
__cocona_APPNAMEPLACEHOLDER_completion_debug_log "$param" index=$index options_completed=$options_completed prev_is_option=$prev_is_option
if [[ $options_completed -eq 1 ]]; then
__cocona_APPNAMEPLACEHOLDER_completion_debug_log "$param" index=$index options_completed=$options_completed prev_is_option=$prev_is_option current_pos=$current_pos
if [[ $current_pos -eq $index ]]; then
break
elif [[ $options_completed -eq 1 ]]; then
((index++))
prev_is_option=0
elif [[ "$param" = '--' ]]; then
Expand Down Expand Up @@ -149,7 +152,7 @@ __cocona_APPNAMEPLACEHOLDER_completion_handle() {
fi

# arguments...
__cocona_APPNAMEPLACEHOLDER_completion_get_argument_index
__cocona_APPNAMEPLACEHOLDER_completion_get_argument_index $((cword - command_depth))
local index_of_arg=$?
__cocona_APPNAMEPLACEHOLDER_completion_debug_log "argument" index_of_arg=$index_of_arg "type=${argument_types[$index_of_arg]}"
case ${argument_types[$index_of_arg]} in
Expand Down

0 comments on commit 427b40d

Please sign in to comment.