org.chelona.GetCmdLineArgs.scala Maven / Gradle / Ivy
/*
* Copyright (C) 2014, 2015, 2016 Juergen Pfundt
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.chelona
import java.io.File
import scopt._
object GetCmdLineArgs {
case class Config(
validate: Boolean = false,
file: Seq[File] = Seq(),
verbose: Boolean = false,
uid: Boolean = false,
base: String = "http://chelona.org",
fmt: String = "n3",
version: Boolean = false,
trace: Boolean = false
)
val argsParser = new OptionParser[Config]("Cheló̱na") {
head("cheló̱na", "version 1.0")
help("help") text "prints this usage text"
opt[Unit]('v', "verbose").action { (_, c) ⇒ c.copy(verbose = true) } text "give some additional information"
opt[Unit]("version").action { (_, c) ⇒ c.copy(version = true) } text "Cheló̱na version information"
opt[Unit]("validate").action { (_, c) ⇒ c.copy(validate = true) } text "validate input file"
opt[Unit]('t', "trace").action { (_, c) ⇒ c.copy(trace = true) } text "display error trace"
opt[Unit]('u', "uid").action { (_, c) ⇒ c.copy(uid = true) } text "use UID for blank nodes"
opt[String]('b', "base").optional() action { (x, c) ⇒ c.copy(base = x) } text "base URI"
opt[String]('f', "fmt").valueName("n3,json-ld").action((x, c) ⇒ c.copy(fmt = x.toLowerCase())).validate(f ⇒ if (f.equals("n3") || f.equals("json-ld")) success else failure(s"format $f not supported")) text "output format"
arg[File]("").minOccurs(1) maxOccurs (1) valueName ("") action { (x, c) ⇒ c.copy(file = c.file :+ x) } text "input ttl-file"
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy