Cleaned up usage and README

This commit is contained in:
Erik C. Thauvin 2022-09-13 13:00:17 -07:00
parent 3f7ed4792b
commit aa0c3dd81c
3 changed files with 17 additions and 9 deletions

View file

@ -6,25 +6,25 @@
Some very basic instructions: Some very basic instructions:
```sh ```sh
{ clone with git or download the ZIP } # clone with git or download the ZIP
git clone https://github.com/ethauvin/mobibot.git git clone https://github.com/ethauvin/mobibot.git
cd mobibot cd mobibot
{ build with gradle } # build with gradle
./gradlew ./gradlew
cd deploy cd deploy
{ configure the properties } # configure the properties
vi *.properties *.xml vi *.properties *.xml
{ help } # help
java -jar mobibot.jar -h java -jar mobibot.jar -h
{ twitter oauth token request } # twitter oauth token request
java -cp mobibot.jar net.thauvin.erik.mobibot.TwitterOAuth <consumerKey> <consumerSecret> java -cp mobibot.jar net.thauvin.erik.mobibot.TwitterOAuth <consumerKey> <consumerSecret>
{ launch } # launch
/usr/bin/nohup java -jar mobibot.jar & /usr/bin/nohup java -jar mobibot.jar &
``` ```

View file

@ -55,6 +55,11 @@ object Constants {
*/ */
const val DEFAULT_SERVER = "irc.libera.chat" const val DEFAULT_SERVER = "irc.libera.chat"
/**
* CLI command for usage.
*/
const val CLI_CMD = "java -jar ${ReleaseInfo.PROJECT}.jar [OPTIONS]"
/** /**
* Help command line argument. * Help command line argument.
*/ */

View file

@ -34,6 +34,7 @@ package net.thauvin.erik.mobibot
import net.thauvin.erik.mobibot.Utils.appendIfMissing import net.thauvin.erik.mobibot.Utils.appendIfMissing
import net.thauvin.erik.mobibot.Utils.bot import net.thauvin.erik.mobibot.Utils.bot
import net.thauvin.erik.mobibot.Utils.capitalise
import net.thauvin.erik.mobibot.Utils.getIntProperty import net.thauvin.erik.mobibot.Utils.getIntProperty
import net.thauvin.erik.mobibot.Utils.helpCmdSyntax import net.thauvin.erik.mobibot.Utils.helpCmdSyntax
import net.thauvin.erik.mobibot.Utils.helpFormat import net.thauvin.erik.mobibot.Utils.helpFormat
@ -274,18 +275,20 @@ class Mobibot(nickname: String, val channel: String, logsDirPath: String, p: Pro
try { try {
commandLine = parser.parse(options, args) commandLine = parser.parse(options, args)
} catch (e: ParseException) { } catch (e: ParseException) {
System.err.println("CLI Parsing failed. Reason: ${e.message}") System.err.println(e.message)
HelpFormatter().printHelp(Constants.CLI_CMD, options)
exitProcess(1) exitProcess(1)
} }
when { when {
commandLine.hasOption(Constants.HELP_ARG[0]) -> { commandLine.hasOption(Constants.HELP_ARG[0]) -> {
// Output the usage // Output the usage
HelpFormatter().printHelp(Mobibot::class.java.name, options) HelpFormatter().printHelp(Constants.CLI_CMD, options)
} }
commandLine.hasOption(Constants.VERSION_ARG[0]) -> { commandLine.hasOption(Constants.VERSION_ARG[0]) -> {
// Output the version // Output the version
println("${ReleaseInfo.PROJECT} ${ReleaseInfo.VERSION} (${ReleaseInfo.BUILDDATE.toIsoLocalDate()})") println("${ReleaseInfo.PROJECT.capitalise()} ${ReleaseInfo.VERSION}" +
" (${ReleaseInfo.BUILDDATE.toIsoLocalDate()})")
println(ReleaseInfo.WEBSITE) println(ReleaseInfo.WEBSITE)
} }