1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-03-19 09:08:47 +00:00

Add further ADB commands

This commit is contained in:
David 2018-01-04 19:02:07 +00:00
parent 207d64a41f
commit ca72101496
2 changed files with 18 additions and 5 deletions

View File

@ -34,7 +34,7 @@ def test_not_match(script):
@pytest.mark.parametrize('script, new_command', [ @pytest.mark.parametrize('script, new_command', [
('adb puhs test.bin /sdcard/test.bin', 'adb push test.bin /sdcard/test.bin'), ('adb puhs test.bin /sdcard/test.bin', 'adb push test.bin /sdcard/test.bin'),
('adb -s 1111 logcta', 'adb -s 1111 logcat'), ('adb -s 1111 logcta', 'adb -s 1111 logcat'),
('adb -p 666 pulll /sdcard/test.bin', 'adb -p 666 pull /sdcard/test.bin'), ('adb -P 666 pulll /sdcard/test.bin', 'adb -P 666 pull /sdcard/test.bin'),
('adb -d logcatt', 'adb -d logcat'), ('adb -d logcatt', 'adb -d logcat'),
('adb -e reboott', 'adb -e reboot')]) ('adb -e reboott', 'adb -e reboot')])
def test_get_new_command(script, output, new_command): def test_get_new_command(script, output, new_command):

View File

@ -2,16 +2,29 @@ from thefuck.utils import is_app, get_closest, replace_argument
# the most common ADB commands # the most common ADB commands
_ADB_COMMANDS = [ _ADB_COMMANDS = (
'backup',
'bugreport',
'connect',
'devices', 'devices',
'disconnect',
'forward',
'install', 'install',
'jdwp',
'kill-server',
'logcat', 'logcat',
'pull', 'pull',
'push', 'push',
'reboot', 'reboot',
'reconnect',
'restore',
'reverse',
'run-as',
'shell', 'shell',
'start-server',
'sync',
'uninstall' 'uninstall'
] )
def match(command): def match(command):
@ -21,8 +34,8 @@ def match(command):
def get_new_command(command): def get_new_command(command):
for idx, arg in enumerate(command.script_parts[1:]): for idx, arg in enumerate(command.script_parts[1:]):
# allowed params to ADB are d/e/s/p where s and p take additional args # 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' # for example 'adb -s 111 logcat' or 'adb -e logcat'
if not arg[0] == '-' and not command.script_parts[idx] in ('-s', '-p'): if not arg[0] == '-' and not command.script_parts[idx] in ('-s', '-H', '-P', '-L'):
adb_cmd = get_closest(arg, _ADB_COMMANDS) adb_cmd = get_closest(arg, _ADB_COMMANDS)
return replace_argument(command.script, arg, adb_cmd) return replace_argument(command.script, arg, adb_cmd)