zsh-workers
 help / color / mirror / code / Atom feed
* [BUG] adb sideload completion incorrect
@ 2015-06-18 16:13 Isgar
  2015-06-19 16:28 ` Oliver Kiddle
  0 siblings, 1 reply; 4+ messages in thread
From: Isgar @ 2015-06-18 16:13 UTC (permalink / raw)
  To: zsh-workers

Hi,

currently the completion tries
  adb sideload [adb command]

the correct syntax is
  adb sideload [filename]

adb sideload pushes an archive to the connected android device, which
will be flashed onto the system partition.

Seems like an easy fix?

Cheers


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [BUG] adb sideload completion incorrect
  2015-06-18 16:13 [BUG] adb sideload completion incorrect Isgar
@ 2015-06-19 16:28 ` Oliver Kiddle
  0 siblings, 0 replies; 4+ messages in thread
From: Oliver Kiddle @ 2015-06-19 16:28 UTC (permalink / raw)
  To: Isgar; +Cc: zsh-workers

Isgar wrote:
> 
> currently the completion tries
>   adb sideload [adb command]
> 
> the correct syntax is
>   adb sideload [filename]

Sigh. Not breaking file completion where it might be wanted is probably
the most important rule for writing completion functions.

> Seems like an easy fix?

I'm not familiar with adb and as it all requires a device to connect to
I can't easily install it to play with. This patch will hopefully do the
trick. It adds two fallback calls to _default. In the first case, it
should perhaps instead be _alternative for both subcommands and files
but it would really need more doing to it than that.
I mostly tried to make the minimal changes to get back file completion.
The one aside fix is to the format of $curcontext which it was breaking
by using : to separate command and subcommand.

Oliver

diff --git a/Completion/Unix/Command/_adb b/Completion/Unix/Command/_adb
index e687762..c05cc02 100644
--- a/Completion/Unix/Command/_adb
+++ b/Completion/Unix/Command/_adb
@@ -76,7 +76,8 @@ _adb() {
 	'(-d -e   )-s[serial]: :_adb_device_serial' \
 	'(   -e -s)-d[device]' \
 	'(-d    -s)-e[emulator]' \
-	'*:"options":_adb_options_handler'
+	'1:"options":_adb_options_handler' \
+	'*: : _default'
       
       return;
   }
@@ -99,27 +100,30 @@ _adb_dispatch_command () {
   fi
 
   case ${curcontext} in
-    (*:adb:shell)
+    (*:adb-shell)
       (( $+functions[_adb_dispatch_shell] )) && _adb_dispatch_shell
       ;;
-    (*:adb:connect|*:adb:disconnect)
+    (*:adb-connect|*:adb-disconnect)
       (( $+functions[_adb_dispatch_connection_handling] )) && _adb_dispatch_connection_handling
       ;;
-    (*:adb:logcat)
+    (*:adb-logcat)
       (( $+functions[_adb_dispatch_logcat] )) && _adb_dispatch_logcat
       ;;
-    (*:adb:push)
+    (*:adb-push)
       (( $+functions[_adb_dispatch_push] )) && _adb_dispatch_push
       ;;
-    (*:adb:pull)
+    (*:adb-pull)
       (( $+functions[_adb_dispatch_pull] )) && _adb_dispatch_pull
       ;;
-    (*:adb:install)
+    (*:adb-install)
       (( $+functions[_adb_dispatch_install] )) && _adb_dispatch_install
       ;;
-    (*:adb:uninstall)
+    (*:adb-uninstall)
       (( $+functions[_adb_dispatch_uninstall] )) && _adb_dispatch_uninstall
       ;;
+    (*:adb-*)
+      _default
+      ;;
     (*)
       _arguments \
 	'(-d -e)-s["serial"]: :_adb_device_serial' \
@@ -143,7 +147,7 @@ _adb_sanitize_context () {
   done
   ##expand unquoted to remove sparse elements
   mywords=( ${mywords[@]} )
-  curcontext="${curcontext}${mywords[-1]}"
+  (( $#mywords )) && curcontext="${curcontext%:*}-${mywords[-1]}:"
 }
 
 (( $+functions[_adb_device_specification] )) ||
@@ -373,9 +377,9 @@ _adb_dispatch_connection_handling () {
   fi
 }
 
-(( $+functions[adb_check_log_redirect] )) ||
+(( $+functions[_adb_check_log_redirect] )) ||
 _adb_check_log_redirect () {
-  LOG_REDIRECT=${$(adb ${=ADB_DEVICE_SPECIFICATION} shell getprop log.redirect-stdio)//
+  LOG_REDIRECT=${$(adb ${=ADB_DEVICE_SPECIFICATION} shell getprop log.redirect-stdio 2>/dev/null)//
 /}
   [[ ${LOG_REDIRECT[1,4]} == "true" ]] &&  _message -r "Notice: stdio log redirection enabled on the device, so some completions will not work"
 }


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [BUG] 'adb sideload' completion incorrect
  2015-06-18 16:05 [BUG] 'adb sideload' " Isgar
@ 2015-06-19  2:42 ` Bart Schaefer
  0 siblings, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 2015-06-19  2:42 UTC (permalink / raw)
  To: Isgar, zsh-workers

On Jun 18,  6:05pm, Isgar wrote:
}
} the correct syntax is
}   adb sideload [filename]
} 
} Seems like a simple fix?

You'd think so, but then you probably haven't looked at the _adb function.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [BUG] 'adb sideload' completion incorrect
@ 2015-06-18 16:05 Isgar
  2015-06-19  2:42 ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Isgar @ 2015-06-18 16:05 UTC (permalink / raw)
  To: zsh-workers

Hi,

completion is currently trying
  adb sideload [adb command]

the correct syntax is
  adb sideload [filename]

adb sideload pushes an archive to the android device, which will be
flashed onto the system partition.

Seems like a simple fix?

Cheers


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-06-19 16:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-18 16:13 [BUG] adb sideload completion incorrect Isgar
2015-06-19 16:28 ` Oliver Kiddle
  -- strict thread matches above, loose matches on Subject: below --
2015-06-18 16:05 [BUG] 'adb sideload' " Isgar
2015-06-19  2:42 ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).