Skip to content

Commit

Permalink
Change help so it's shorted by default and has a nicer layout
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-xo committed Apr 16, 2022
1 parent aefce7b commit 439f0ef
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 52 deletions.
47 changes: 31 additions & 16 deletions SSL/HistoryReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class HistoryReader implements SSLPluggable, SSLFilenameSource
protected $dir_provided = false;
protected $help = false;
protected $debug_help = false;
protected $plugin_help = false;
protected $manual_tick = false;
protected $time_multiplier = 1.0;
protected $csv = false;
Expand Down Expand Up @@ -137,7 +138,7 @@ public function main($argc, array $argv)

if($this->help)
{
$this->usage($this->appname, $argv, $this->debug_help);
$this->usage($this->appname, $argv, $this->debug_help, $this->plugin_help);
return;
}

Expand Down Expand Up @@ -235,42 +236,49 @@ public function main($argc, array $argv)
}
}

public function usage($appname, array $argv, $debug_help=false)
public function usage($appname, array $argv, $debug_help=false, $plugin_help=false)
{
echo "\n";
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 " -h or --help: This message. You probably want to read --plugin-help too.\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";
echo " -l or --log-file <file>: Where to send logging output instead of stdout.\n";
if(!$this->has_now_playing_plugin) {
echo "\n **Note:** For options to log the current playing track title into a file for live streams etc., enable CLINowPlayingLoggerPlugin in config.php (see example on config.php-default).\n\n";
}
echo " -p or --post-process: Loop through the session file after your DJ set is finished. \n";
echo " You can use this to e.g. scrobble a set you played whilst offline.\n\n";
echo " -i or --immediate: Do not wait for a session file to be created - use the current one. \n";
echo " You want this if Serato is already running.\n\n";
echo " --dir: Use the most recent session file from this here instead.\n";
echo " This is the option for you if we couldn't correctly guess where your Serato data lives.\n\n";
echo " --plugin-help: Show help for for all of the activated plugins\n";
echo " e.g. Twitter, Last FM, Discord, etc - all the good stuff.\n\n";
echo " --debug-help: Show help for options not usually used during a DJ set.\n";
echo "\n";

foreach($this->cli_plugins as $plugin)
if($plugin_help)
{
/* @var $plugin CLIPlugin */
$plugin->usage($appname, $argv);
foreach($this->cli_plugins as $plugin)
{
/* @var $plugin CLIPlugin */
$plugin->usage($appname, $argv);
}
}
echo "\n";

if($debug_help)
{
echo "Debugging options:\n";
echo " -d or --dump: Dump the file's complete structure and exit\n";
echo " Note that whenever the help mentions a session file, it will be the most recent found unless you specified a specific file.\n\n";
echo " -d or --dump: Dump the file's complete structure, then exit.\n";
echo " --dump-type <x>: Use a specific parser. Options are: sessionfile, sessionindex\n";
echo " -v or --verbosity <0-9>: How much logging to output. (default: 0 (none))\n";
echo " -v or --verbosity <0-9>: How much logging to output. default: " . (string)L::INFO . " (INFO)\n";
echo " --manual: Replay the session file, one batch per tick. (Tick by pressing enter at the console)\n";
echo " --multiply-time <n>: Speed up time by a factor of n\n";
echo " --multiply-time <N>: Speed up time by a factor of N whilst in --manual mode.\n";
echo " --csv: Parse the session file as a CSV, not a binary file, for testing purposes. Best used with --manual\n";
}
else
{
echo " --debug-help: Show help about debugging options.\n";
}
echo "\n";
}

Expand Down Expand Up @@ -368,6 +376,13 @@ protected function parseOptions(array $argv)
$this->debug_help = true;
continue;
}

if($arg == '--plugin-help')
{
$this->help = true;
$this->plugin_help = true;
continue;
}

if($arg == '--dump' || $arg == '-d')
{
Expand Down
11 changes: 6 additions & 5 deletions SSL/Plugins/DB/CLIDBPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,13 @@ public function setConfig(array $config)

public function usage($appname, array $argv)
{
echo "DB options:\n";
echo " -D or --db <key>: run an SQL statement based on <key> and the track name (edit config.php for the SQL)\n";
echo " Current configured statement is:\n";
echo " ";
echo "DB options:\n\n"
. " -D or --db <key>:\n"
. " run an SQL statement based on <key> and the track name (edit config.php for the SQL)\n"
. " Current configured statement is:\n\n"
. " ";
printf($this->config['sql'], '<trackname>', '<key>');
echo "\n";
echo "\n\n\n";
}

/**
Expand Down
8 changes: 5 additions & 3 deletions SSL/Plugins/Discord/CLIDiscordPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ public function setConfig(array $config)

public function usage($appname, array $argv)
{
echo "Discord options:\n";
echo " --discord <session>: Post tracklists to Discord. <session> is a 'save name' for the session. You will be guided through creating a bot if this is the first time.\n";
echo "\n";
echo "Discord options:\n\n"
. " --discord <session>:\n"
. " Post tracklists to Discord. <session> is a 'save name' for the session.\n"
. " You will be guided through creating a bot if this is the first time.\n\n"
. "\n";
}

/**
Expand Down
7 changes: 4 additions & 3 deletions SSL/Plugins/IrcCat/CLIIrcCatPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ public function setConfig(array $config)

public function usage($appname, array $argv)
{
echo "IRCCat options:\n";
echo " -I or --irccat <host:port#channel>: Post tracklists to IRCCat on <host:port> into channel <#channel>.\n";
echo "\n";
echo "IRCCat options:\n\n"
. " -I or --irccat <host:port#channel>:\n"
. " Post tracklists to IRCCat on <host:port> into channel <#channel>.\n\n"
. "\n";
}

/**
Expand Down
25 changes: 12 additions & 13 deletions SSL/Plugins/JsonServer/CLIJsonServerPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,18 @@ public function setConfig(array $config)

public function usage($appname, array $argv)
{
echo "JSON / HTML Server options:\n";
echo " -J or --json <port>\n";
echo " or -H or --html <port> : Enable local web server for the details of the current playing track.\n";
echo " The info will be available as JSON at http:https://<your ip>:<port>/nowplaying.json and\n";
echo " also as HTML for styling with OBS at http:https://<your ip>:<port>/nowplaying.html\n";
echo "\n";
echo " If OBS runs on the same computer you can use URLs such as http:https://localhost:<port>/nowplaying.html\n";
echo "\n";
echo " By default, all available fields are displayed, but you can narrow it down to just the fields you want\n";
echo " using URLs such as http:https://<your ip>:<port>/nowplaying.html?artist&title which you can style with CSS.\n";
echo "\n";
echo " --html-template <file>: A optional file containing strings like {{artist}} or {{title}}.\n";
echo "\n";
echo "JSON / HTML Server options:\n\n"
. " -J or --json <port>\n"
. " or -H or --html <port> :\n"
. " Enable local web server for the details of the current playing track.\n"
. " The info will be available as JSON at http:https://<your ip>:<port>/nowplaying.json and\n"
. " also, as HTML for styling with OBS at http:https://<your ip>:<port>/nowplaying.html\n\n"
. " If OBS runs on the same computer you can use URLs such as http:https://localhost:<port>/nowplaying.html\n\n"
. " By default, all available fields are displayed, but you can narrow it down to just the fields you want\n"
. " using URLs such as http:https://<your ip>:<port>/nowplaying.html?artist&title which you can style with CSS.\n\n"
. " --html-template <file>:\n"
. " A optional file containing strings like {{artist}} or {{title}}.\n\n"
. "\n";
}

/**
Expand Down
8 changes: 5 additions & 3 deletions SSL/Plugins/Last.fm/CLILastfmPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ public function setConfig(array $config)

public function usage($appname, array $argv)
{
echo "Last.fm options:\n";
echo " -L or --lastfm <username>: Scrobble / send 'Now Playing' to Last.fm for user <username>. (Will ask you to authorize if you have not already)\n";
echo "\n";
echo "Last.fm options:\n\n"
. " -L or --lastfm <username>:"
. " Scrobble / send 'Now Playing' to Last.fm for user <username>.\n"
. " (Will ask you to authorize if you have not already)\n\n"
. "\n";
}

/**
Expand Down
15 changes: 10 additions & 5 deletions SSL/Plugins/NowPlaying/CLINowPlayingLoggerPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,16 @@ class CLINowPlayingLoggerPlugin implements CLIPlugin

public function usage($appname, array $argv)
{
echo "Log 'Now Playing' Track options:\n";
echo " -ln or --log-track <file>: log the current playing track to a file (e.g. for streaming)\n";
echo " -ls or --log-serialized <file>: log the current playing track to a file in PHP serialized form (contains more info, but not human readable)\n";
echo " -lt or --log-tostring <file>: log the current playing track to a file in a fuller representation like in the logs\n";
echo "\n";
echo "Log 'Now Playing' Track options:\n\n"
. " -ln or --log-track <file>:\n"
. " log the current playing track to a file (e.g. for streaming)\n\n"
. " -ls or --log-serialized <file>:\n"
. " log the current playing track to a file in PHP serialized form.\n"
. " (contains more info, but not human readable)\n\n"
. " -lt or --log-tostring <file>: \n"
. " log the current playing track to a file in the same, fuller\n"
. " representation used in the console output.\n\n"
. "\n";
}

/**
Expand Down
11 changes: 7 additions & 4 deletions SSL/Plugins/Twitter/CLITwitterPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,13 @@ public function setConfig(array $config)

public function usage($appname, array $argv)
{
echo "Twitter options:\n";
echo " -T or --twitter <session>: Post tracklists to Twitter. <session> is a 'save name' for the session. (Will ask you to authorize if you have not already)\n";
echo " --twitter-thread <session>: Post as replies, so they appear in a single thread.\n";
echo "\n";
echo "Twitter options:\n\n"
. " -T or --twitter <session>:\n"
. " Post tracklists to Twitter. <session> is a 'save name' for the session.\n"
. " (Will ask you to authorize if you have not already done so)\n\n"
. " --twitter-thread <session>:\n"
. " Post as replies, so they appear in a single thread.\n\n"
. "\n";
}

/**
Expand Down

0 comments on commit 439f0ef

Please sign in to comment.