in dev/src/main/scala/com/gu/anghammarad/Main.scala [75:90]
def notificationFromArguments(args: Arguments): Try[Notification] = {
args match {
case JsonArgs(subject, jsonStr, _) =>
for {
json <- parse(jsonStr).toTry
notification <- Serialization.generateNotification(subject, json)
} yield notification
case Specified(subject, message, actions, targets, Some(channel), source, _, _, threadKey) =>
Success(Notification(subject, message, actions, targets, channel, source, threadKey))
case s: Specified =>
Fail("No channel provided")
case InitialArgs =>
argParser.showUsageOnError
Fail("No arguments provided, cannot make a notification")
}
}