Skip to content

Commit

Permalink
Merge pull request xmlcalabash#10 from ndw/add-config
Browse files Browse the repository at this point in the history
Support config changes in the API
  • Loading branch information
ndw committed Oct 24, 2021
2 parents 1ee50c3 + 66bc6bc commit f65cfb2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/main/scala/com/xmlcalabash/util/ArgBundle.scala
Expand Up @@ -91,6 +91,10 @@ class ArgBundle() {
_parameters += new PipelineInputText(port, text, contentType)
}

def input(port: String, text: String, contentType: String): Unit = {
_parameters += new PipelineInputText(port, text, MediaType.parse(contentType))
}

def output(port: String, document: String): Unit = {
_parameters += new PipelineOutputFilename(port, document)
}
Expand Down Expand Up @@ -147,6 +151,22 @@ class ArgBundle() {
_parameters += new PipelineExpressionOption(eqname, value)
}

def config(eqname: String, value: String): Unit = {
if (eqname == "file" || eqname == "Q{}file" || eqname == s"Q{${XProcConstants.ns_cc}}file") {
_parameters += new PipelineConfigurationFile(new PipelineFilenameDocument(value))
} else {
if (eqname.contains("{")) {
_parameters += new PipelineEnvironmentOptionString(eqname, value)
} else {
_parameters += new PipelineEnvironmentOptionString(s"Q{${XProcConstants.ns_cc}}${eqname}", value)
}
}
}

def config(name: QName, value: String): Unit = {
config(name.getEQName, value)
}

def parse(args: List[String]): Unit = {
// -iport=input | --input port=input
// -oport=output | --output port=output
Expand Down
Expand Up @@ -110,6 +110,7 @@ class PipelineEnvironmentOptionString(eqname: String, val value: String) extends
}
}
override def getString: Option[String] = Some(value)
override def toString: String = s"config: ${eqname} = ${value}"
}

class PipelineEnvironmentOptionMap(eqname: String, var key: String, var value: String) extends PipelineEnvironmentOption(eqname) {
Expand Down

0 comments on commit f65cfb2

Please sign in to comment.