Skip to content

Commit

Permalink
Refactor CLI code to get babel-ified and generally be more maintainab…
Browse files Browse the repository at this point in the history
…le (#114)

* Begin initial CLI refactor

Refs #108

The general approach here is that each command should be simple to write
with an easy means of operating against a provided UI and device. That
way we can test against mocks/fakes and also easily swap out a different
"UI" implementation. I don't plan to add a GUI, but this would make it
easier to support `--json` mode, or even possibly a headless stdin-based
daemon mode.

I've decided against oclif because it just seems like too much, but
commander.js or yargs seem like good options.

* Restore some logging

* Improve cli test correctness; support inline PIN prompts

Closes #113

* Implement command routing using our old friend minimist

Refs #108

Yargs has some great stuff but I don't like how it renders the options
info. Commander.js seems very close, but it doesn't wrap descriptions at
all. docopt and neodoc seem neat but don't let us nicely and succinctly
describe what each command does.

Minimist is simple and easy, and doesn't introduce any new dependency
overhead, so let's just stick with it!

* Remove old bin script and udpate package.json

* Update readme with latest, cleaned up help text

Closes #108
  • Loading branch information
dhleong authored Mar 9, 2019
1 parent 1034d73 commit 3ba552f
Show file tree
Hide file tree
Showing 23 changed files with 1,825 additions and 1,549 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = {
"ecmaVersion": 2018
},
"rules": {
"class-methods-use-this": "off",
"arrow-body-style": "off",
"func-names": "off", // for now
"indent": ["error", 4],
Expand Down
50 changes: 28 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,43 +29,49 @@ to get the following usage information:
ps4-waker - Wake your PS4 (and more!) with help from the Playstation App
Usage:
ps4-waker [options] Wake PS4 device(s)
ps4-waker [options] osk-submit (text) Submit the OSK, optionally providing the text
ps4-waker [options] remote <key-name> (...<key-name>) Send remote key-press event(s)
ps4-waker [options] search Search for devices
ps4-waker [options] standby Request the device enter standby/rest mode
ps4-waker [options] start <titleId> Start a specified title id
ps4-waker --help | -h | -? Shows this help message.
ps4-waker --version | -v Show package version.
ps4-waker [options] Wake PS4 device(s)
ps4-waker [options] osk-submit [text] Submit the OSK, optionally
providing the text
ps4-waker [options] remote <key-name...> Send remote key-press event(s)
ps4-waker [options] search Search for devices
ps4-waker [options] standby Request the device enter
standby/rest mode
ps4-waker [options] start <titleId> Start a specified title id
ps4-waker --help | -h | -? Shows this help message.
ps4-waker --version | -v Show package version.
Options:
--bind | -b <ip> Bind to a specific network adapter IP, if you have multiple
--bind-port | -p <port> Bind on a specific port, if you need to route specifically
--bind | -b <ip> Bind to a specific network adapter IP, if
you have multiple
--bind-port | -p <port> Bind on a specific port, if you need to
route specifically
--credentials | -c <file> Specify credentials file
--device | -d <ip> Specify IP address of a specific PS4
--failfast Don't request credentials if none
--skip-login Don't automatically login
--pin <pin-code> Manual pin-code registration
--pass <passcode> Provide passcode for login, if needed
--timeout | -t <time> Stop searching after <time> milliseconds; the default timeout
unspecified is 10 seconds
--timeout | -t <time> Stop searching after <time> milliseconds;
the default timeout, if unspecified, is 10
seconds
Device selection:
For any command, there are four possible conditions based on the flags you've specified:
1. Neither -t nor -d: Will act on the first device found; this is for households
with a single device on the network
For any command, there are four possible conditions based on the flags
you've specified:
1. Neither -t nor -d: Will act on the first device found; this is for
households with a single device on the network
2. Just -t: Will act on every device found within <time> millseconds
3. Just -d: Will search for at most 10 seconds (the default timeout) for and only act on
the provided device, quitting if found
4. Both -t and -d: Will search for at most <time> seconds for and only act on the
provided device, qutting early if found.
3. Just -d: Will search for at most 10 seconds (the default timeout)
for and only act on the provided device, quitting if found
4. Both -t and -d: Will search for at most <time> seconds for and only
act on the provided device, qutting early if found.
Key names:
Button names are case insensitive, and can be one of:
up, down, left, right, enter, back, option, ps
You cannot send the actual x, square, etc. buttons
A string of key presses may be provided, separated by spaces,
and they will be sent sequentially.
You cannot send the actual x, square, etc. buttons.
A string of key presses may be provided, separated by spaces, and they
will be sent sequentially.
In addition, a key name may be followed by a colon and a duration in
milliseconds to hold that key, eg: ps4-waker remote ps:1000
```
Expand Down
317 changes: 0 additions & 317 deletions bin/.eslintrc.js

This file was deleted.

Loading

0 comments on commit 3ba552f

Please sign in to comment.