feat: completion for adb push and pull (#8901)

This commit is contained in:
NextAlone 2022-04-27 03:14:02 +08:00 committed by GitHub
parent 8a4ee02d24
commit b032354a9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -75,6 +75,22 @@ function __fish_adb_list_files
__fish_adb_run_command find -H "$token*" -maxdepth 0 -type f 2\>/dev/null
end
function __fish_adb_completion_for_pull
set -l token (commandline -opc)
__fish_adb_list_files
if test (count $token) -gt 2
__fish_complete_path
end
end
function __fish_adb_completion_for_push
set -l token (commandline -opc)
__fish_complete_path
if test (count $token) -gt 2
__fish_adb_list_files
end
end
# Generic options, must come before command
complete -n __fish_adb_no_subcommand -c adb -s s -x -a "(__fish_adb_get_devices)" -d 'Device to communicate with'
@ -164,4 +180,5 @@ complete -n '__fish_seen_subcommand_from reconnect' -c adb -x -a device -d 'Kick
# commands that accept listing device files
complete -n '__fish_seen_subcommand_from shell' -c adb -f -a "(__fish_adb_list_files)" -d 'File on device'
complete -n '__fish_seen_subcommand_from pull' -c adb -f -a "(__fish_adb_list_files)" -d 'File on device'
complete -n '__fish_seen_subcommand_from pull' -c adb -f -a "(__fish_adb_completion_for_pull)" -d 'File on device'
complete -n '__fish_seen_subcommand_from push' -c adb -f -a "(__fish_adb_completion_for_push)" -d 'File on device'