Add rule for ADB unknown commands (#765)

This commit is contained in:
David Hart
2018-01-05 21:20:03 +00:00
committed by Joseph Frazier
parent b62bb90a0d
commit 7b10a86267
3 changed files with 96 additions and 0 deletions
+54
View File
@@ -0,0 +1,54 @@
from thefuck.utils import is_app, get_closest, replace_argument
_ADB_COMMANDS = (
'backup',
'bugreport',
'connect',
'devices',
'disable-verity',
'disconnect',
'enable-verity',
'emu',
'forward',
'get-devpath',
'get-serialno',
'get-state',
'install',
'install-multiple',
'jdwp',
'keygen',
'kill-server',
'logcat',
'pull',
'push',
'reboot',
'reconnect',
'restore',
'reverse',
'root',
'run-as',
'shell',
'sideload',
'start-server',
'sync',
'tcpip',
'uninstall',
'unroot',
'usb',
'wait-for',
)
def match(command):
return (is_app(command, 'adb')
and command.output.startswith('Android Debug Bridge version'))
def get_new_command(command):
for idx, arg in enumerate(command.script_parts[1:]):
# allowed params to ADB are a/d/e/s/H/P/L where s, H, P and L take additional args
# for example 'adb -s 111 logcat' or 'adb -e logcat'
if not arg[0] == '-' and not command.script_parts[idx] in ('-s', '-H', '-P', '-L'):
adb_cmd = get_closest(arg, _ADB_COMMANDS)
return replace_argument(command.script, arg, adb_cmd)