Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions core/js/src/main/scala/com/monovore/decline/PlatformApp.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.monovore.decline

import scala.scalajs.js
import scala.scalajs.js.annotation.JSGlobalScope
import js.Dynamic.global

object PlatformApp {

Expand All @@ -21,4 +22,10 @@ object PlatformApp {
* otherwise.
*/
def ambientArgs: Option[Seq[String]] = Process.process.toOption.map { _.argv.drop(2).toSeq }

private lazy val process = global.require("process")
def exit(code: Int): Nothing = {
process.exit(code)
sys.error(s"Attempt to exit with code $code failed")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ object PlatformApp {
* otherwise.
*/
def ambientArgs: Option[Seq[String]] = None

def exit(code: Int): Nothing = {
sys.exit(code)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ object PlatformApp {
* otherwise.
*/
def ambientArgs: Option[Seq[String]] = None

def exit(code: Int): Nothing = {
sys.exit(code)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ For suggested usage, see: http://monovore.com/decline/usage.html#defining-an-app
)
final def main(args: Array[String]): Unit =
command.parse(PlatformApp.ambientArgs getOrElse args, sys.env) match {
case Left(help) => System.err.println(help)
case Left(help) =>
System.err.println(help)
PlatformApp.exit(1)
case Right(_) => ()
}
}