✨ Add commands
This commit is contained in:
parent
3f94331977
commit
e829316070
1 changed files with 40 additions and 1 deletions
41
main.js
41
main.js
|
@ -2,7 +2,7 @@ import { exec } from 'node:child_process';
|
||||||
|
|
||||||
import { overrideConsole } from 'nodejs-better-console';
|
import { overrideConsole } from 'nodejs-better-console';
|
||||||
import Eris from 'eris';
|
import Eris from 'eris';
|
||||||
import { Command } from 'commander';
|
import { Command, Argument } from 'commander';
|
||||||
import KeyEvent from 'keyevent.json' assert { type: 'json' };
|
import KeyEvent from 'keyevent.json' assert { type: 'json' };
|
||||||
import { parse } from 'shell-quote';
|
import { parse } from 'shell-quote';
|
||||||
|
|
||||||
|
@ -51,6 +51,16 @@ const
|
||||||
isRaw: true
|
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
|
program
|
||||||
.command('p')
|
.command('p')
|
||||||
.description('Play/pause media')
|
.description('Play/pause media')
|
||||||
|
@ -63,6 +73,30 @@ const
|
||||||
.command('pause')
|
.command('pause')
|
||||||
.description('Pause media')
|
.description('Pause media')
|
||||||
.action(() => adb(`input keyevent ${KeyEvent.KEYCODE_MEDIA_PAUSE}`));
|
.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
|
program
|
||||||
.command('spotify')
|
.command('spotify')
|
||||||
.description('Launch Spotify')
|
.description('Launch Spotify')
|
||||||
|
@ -72,6 +106,11 @@ const
|
||||||
.description('Launch MPV')
|
.description('Launch MPV')
|
||||||
.argument('<url>', 'Media URL')
|
.argument('<url>', 'Media URL')
|
||||||
.action(url => adb(`am start -a android.intent.action.VIEW -d ${url} -t video/any is.xyz.mpv`));
|
.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 {
|
try {
|
||||||
await program.parseAsync(
|
await program.parseAsync(
|
||||||
parse(command),
|
parse(command),
|
||||||
|
|
Loading…
Reference in a new issue