Skip to content

Commit

Permalink
Merge pull request #31 from ben-xo/feature/document-prompt-mode
Browse files Browse the repository at this point in the history
Feature/document prompt mode
  • Loading branch information
ben-xo authored Apr 15, 2022
2 parents 2272646 + 44e3a48 commit 2e5a049
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 20 deletions.
47 changes: 30 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ already have a session open.
## 1.1 Installation


* OSX (Mac):
### 1.1.1 macOS

There is an app you can download from https://github.com/ben-xo/sslscrobbler/releases

Expand All @@ -65,13 +65,11 @@ already have a session open.
See "Getting Started" for more.


* Windows Vista, 7, 8, 10 or 11:
### 1.1.2 Windows

I haven't tested this part in a while - try installing PHP from
http://www.anindya.com/ or following the instructions on https://www.php.net/

* Windows:

You should install PHP 8 and Growl. You must reboot after installing these,
even if it doesn't ask!

Expand All @@ -86,21 +84,25 @@ already have a session open.

display_errors =

...and change it to On if it is Off.
...and change it to `On` if it is `Off`.

SSLScrobbler is best started from a DOS box / Command prompt.
SSLScrobbler is best started from a DOS box / Command prompt (see below)


## 1.2 Getting Started


SSLScrobbler is designed to be run from the command line, but on macOS there is
a simple GUI to help you get started.
SSLScrobbler is designed to be run from the command prompt / terminal, but on
macOS there is also a GUI to help you get started.


### 1.2.1 TO START

**TO START**:
I use this app through Terminal on macOS. But, there is a macOS GUI version too.
On Windows you must use Command Prompt. There is a guided-prompt setup mode.
Read on.

*macOS (super-easy method):*
#### 1.2.1.1 macOS (super-easy method):

The simplest way to get started is to use the macOS app.
* Download the macOS.zip file from https://github.com/ben-xo/sslscrobbler/releases
Expand All @@ -111,7 +113,7 @@ The simplest way to get started is to use the macOS app.
* Then start Serato DJ and watch what happens!


*macOS (traditional method / more options):*
#### 1.2.1.2 macOS (traditional method / more options):

It is more flexible when used from Terminal.

Expand All @@ -124,14 +126,17 @@ It is more flexible when used from Terminal.
* For help and information on options, type `--help` before hitting enter. e.g:

$ ./historyreader.php --help

*Windows:*

* For the guided setup mode, try `--prompt` .


#### 1.2.1.3 Windows:

There's no GUI version for Windows yet. Sorry.

* Open a DOS box. You can do this by clicking 'Start' -> Run -> typing "cmd"
* Open a Command Prompt. You can do this by clicking 'Start' -> Run -> typing "`cmd`"
and pressing enter.
* Type `php` and then drag the file `historyreader.php` into the DOS box, and hit
* Type `php` and then drag the file `historyreader.php` into the command prompt, and hit
enter. It should say something like:

C:\> php "C:\Documents and Settings\ben\Desktop\historyreader.php"
Expand All @@ -140,10 +145,12 @@ It is more flexible when used from Terminal.

C:\> php "C:\Documents and Settings\ben\Desktop\historyreader.php" --help

* For guided setup mopde, try `--prompt` .


**TO QUIT:**
### 1.2.2 TO QUIT

To quit SSL Scrobbler, click on its window and press Ctrl-C.
To quit SSL Scrobbler, click on its window and press `Ctrl`+`C`.
(or in the macOS app, press the quit button in the bottom right)


Expand Down Expand Up @@ -193,6 +200,12 @@ Add the following options to the command when running from Terminal / DOS:
`-h` or `--help`
A reminder of this information.

`--prompt`
Guided setup mode.

You will be asked a series of yes or no questions. (Not all options are available
in this mode).

`-i` or `--immediate`
Do not wait for the next history file to be created, but use the most recent
one.
Expand Down
45 changes: 43 additions & 2 deletions SSL/HistoryReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ public function usage($appname, array $argv, $debug_help=false)
echo "Usage: {$appname} [OPTIONS] [session file]\n";
echo "Session file is optional. If omitted, the most recent history file from {$this->historydir} will be used automatically\n";
echo " -h or --help: This message.\n";
echo " --prompt: Guided setup mode.\n";
echo " -i or --immediate: Do not wait for the next history file - use the current one. You want this if Serato is already running.\n";
echo " -p or --post-process: Loop through the file after the fact. Use for scrobbling a set you played with no internet.\n";
echo " --dir: Use the most recent history file from this directory.\n";
Expand Down Expand Up @@ -307,6 +308,10 @@ protected function getDefaultHistoryDir()

protected function parseOptions(array $argv)
{
// in case of --prompt we need the original
$argv_copy = $argv;
$prompted = false;

$this->appname = array_shift($argv);

while($arg = array_shift($argv))
Expand All @@ -319,14 +324,41 @@ protected function parseOptions(array $argv)

if($arg == '--prompt')
{
$this->addPrompts($argv);
// we only want to do this once (in case of double --prompt or two prompt types)
if(!$prompted) {
$prompted = true;
$argv_before_length = sizeof($argv);

$this->addPrompts($argv);

// we want to show the equivalent output that --prompt generated.
$argv_copy = array_merge($argv_copy, array_slice($argv, $argv_before_length));

// remove --prompt
$key = array_search($arg, $argv_copy);
unset($argv_copy[$key]);
}
continue;
}

if($arg == '--prompt-osascript')
{
Inject::map('PromptFactory', new OsascriptPromptFactory());
$this->addPrompts($argv);

// we only want to do this once (in case of double --prompt or two prompt types)
if(!$prompted) {
$prompted = true;
$argv_before_length = sizeof($argv);

$this->addPrompts($argv);

// we want to show the equivalent output that --prompt generated.
$argv_copy = array_merge($argv_copy, array_slice($argv, $argv_before_length));

// remove --prompt
$key = array_search($arg, $argv_copy);
unset($argv_copy[$key]);
}
continue;
}

Expand Down Expand Up @@ -410,6 +442,15 @@ protected function parseOptions(array $argv)

$this->filename = $arg;
}

if($prompted)
{
echo "\n";
echo "The equivalent command line for your prompt is:\n";
echo "\n";
echo "\t" . implode(" ", $argv_copy) . "\n";
echo "\n";
}
}

public function setupLogging()
Expand Down
2 changes: 1 addition & 1 deletion SSL/Plugins/DiscordPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ protected function authDiscord($save_name)
return;
}

throw new RuntimeException("Failed to save {$bot_or_bearer} token to discord-{$save_name}.txt");
throw new RuntimeException("Failed to save webhook URL to discord-{$save_name}.txt");
}

/**
Expand Down

0 comments on commit 2e5a049

Please sign in to comment.