Add commands

This commit is contained in:
KaKi87 2024-01-27 20:38:33 +01:00
parent 3f94331977
commit e829316070

41
main.js
View file

@ -2,7 +2,7 @@ import { exec } from 'node:child_process';
import { overrideConsole } from 'nodejs-better-console';
import Eris from 'eris';
import { Command } from 'commander';
import { Command, Argument } from 'commander';
import KeyEvent from 'keyevent.json' assert { type: 'json' };
import { parse } from 'shell-quote';
@ -51,6 +51,16 @@ const
isRaw: true
}
});
program
.command('home')
.alias('h')
.description('Go to home')
.action(() => adb(`input keyevent ${KeyEvent.KEYCODE_HOME}`));
program
.command('back')
.alias('b')
.description('Go back')
.action(() => adb(`input keyevent ${KeyEvent.KEYCODE_BACK}`));
program
.command('p')
.description('Play/pause media')
@ -63,6 +73,30 @@ const
.command('pause')
.description('Pause media')
.action(() => adb(`input keyevent ${KeyEvent.KEYCODE_MEDIA_PAUSE}`));
program
.command('prev')
.description('Previous media')
.action(() => adb(`input keyevent ${KeyEvent.KEYCODE_MEDIA_PREVIOUS}`));
program
.command('next')
.description('Next media')
.action(() => adb(`input keyevent ${KeyEvent.KEYCODE_MEDIA_NEXT}`));
program
.command('type')
.description('Type text')
.argument('<text>', 'Text to type')
.action(text => adb(`input text ${text}`));
program
.command('press')
.description('Press key')
.addArgument(
new Argument('<key>', 'Key to press')
.choices(['tab', 'shift-tab', 'enter'])
)
.action(key => adb(`input keyevent ${{
'tab': KeyEvent.KEYCODE_TAB,
'enter': KeyEvent.KEYCODE_ENTER
}[key]}`));
program
.command('spotify')
.description('Launch Spotify')
@ -72,6 +106,11 @@ const
.description('Launch MPV')
.argument('<url>', 'Media URL')
.action(url => adb(`am start -a android.intent.action.VIEW -d ${url} -t video/any is.xyz.mpv`));
program
.command('kiwi')
.description('Launch Kiwi browser')
.argument('<url>', 'Website URL')
.action(url => adb(`am start -a android.intent.action.VIEW -d ${url} -t text/plain com.kiwibrowser.browser`));
try {
await program.parseAsync(
parse(command),