summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2021-02-27 20:08:27 +0000
committerJuan J. Martinez <jjm@usebox.net>2021-07-22 19:49:51 +0100
commit28c591fa51ce97c9d5b463582e15d5fe8470ecda (patch)
tree75dc8661c282623eca3ecac130d8d010e1300e5d /server
parentc03e7306ef6ac158e953b254f5ae2f63f6c2bac9 (diff)
downloadspacebeans-28c591fa51ce97c9d5b463582e15d5fe8470ecda.tar.gz
spacebeans-28c591fa51ce97c9d5b463582e15d5fe8470ecda.zip
Moved to use scopt
Removed weight because of transitive dependencies (com.monovore uses cats).
Diffstat (limited to 'server')
-rw-r--r--server/src/net/usebox/gemini/server/ServerApp.scala45
1 files changed, 14 insertions, 31 deletions
diff --git a/server/src/net/usebox/gemini/server/ServerApp.scala b/server/src/net/usebox/gemini/server/ServerApp.scala
index 068ea6b..88e3b32 100644
--- a/server/src/net/usebox/gemini/server/ServerApp.scala
+++ b/server/src/net/usebox/gemini/server/ServerApp.scala
@@ -1,9 +1,5 @@
package net.usebox.gemini.server
-import com.monovore.decline._
-
-import cats.implicits._
-
import org.log4s._
object ServerApp {
@@ -14,38 +10,24 @@ object ServerApp {
val defConfFile = "/etc/spacebeans.conf"
case class ServerOpts(
- version: Boolean,
confFile: String
)
- val opts: Command[ServerOpts] =
- Command(
- name = BuildInfo.name,
- header = appName
- ) {
- (
- Opts
- .flag("version", "Display the version and exit.")
- .orFalse,
- Opts
- .option[String](
- "conf",
- s"Configuration file (default: $defConfFile).",
- short = "c"
- )
- .withDefault(defConfFile)
- ).mapN { (version, confFile) =>
- ServerOpts(version, confFile)
- }
- }
+ val parser = new scopt.OptionParser[ServerOpts](BuildInfo.name) {
+ head(appName, BuildInfo.version)
+
+ opt[String]('c', "conf")
+ .action((x, c) => c.copy(confFile = x))
+ .text(s"Configuration file (default: $defConfFile)")
+
+ help("help").text("Displays this help and exits")
+ version("version")
+ note("\nProject page: https://github.com/reidrac/spacebeans")
+ }
def main(args: Array[String]): Unit =
- opts.parse(args.toIndexedSeq) match {
- case Left(help) =>
- println(help)
- case Right(ServerOpts(true, _)) =>
- println(version)
- case Right(ServerOpts(_, confFile)) =>
+ parser.parse(args, ServerOpts(defConfFile)) match {
+ case Some(ServerOpts(confFile)) =>
ServiceConf.load(confFile) match {
case Left(error) =>
logger
@@ -58,5 +40,6 @@ object ServerApp {
)
Server(conf).serve
}
+ case None => // will display error
}
}