Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rcannood committed Aug 14, 2024
1 parent 147290d commit 921fa8b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function ViashParseArgumentValue {
local env_name="$1"
local multiple="$2"
local flag="$3"
local flag="$1"
local env_name="$2"
local multiple="$3"
local value="$4"

if [ $# -lt 4 ]; then
Expand Down
1 change: 1 addition & 0 deletions src/main/scala/io/viash/helpers/Bash.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ object Bash {
lazy val ViashFindTargetDir: String = readUtils("ViashFindTargetDir")
lazy val ViashDockerFuns: String = readUtils("ViashDockerFuns")
lazy val ViashLogging: String = readUtils("ViashLogging")
lazy val ViashRenderYaml: String = readUtils("ViashRenderYaml")
lazy val ViashParseArgumentValue: String = readUtils("ViashParseArgumentValue")

/**
Expand Down
14 changes: 8 additions & 6 deletions src/main/scala/io/viash/wrapper/BashWrapper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -287,13 +287,15 @@ object BashWrapper {
| VIASH_TEMP=$${VIASH_TEMP:-/tmp}
|fi
|
|# define helper functions
|# bash helper functions start -----------------------------------
|${Bash.ViashQuote}
|${Bash.ViashRemoveFlags}
|${Bash.ViashSourceDir}
|${Bash.ViashFindTargetDir}
|${Bash.ViashLogging}
|${Bash.ViashParseArgumentValue}
|${Bash.ViashRenderYaml}
|# bash helper functions end -------------------------------------
|
|# find source folder of this component
|VIASH_META_RESOURCES_DIR=`ViashSourceDir $${BASH_SOURCE[0]}`
Expand Down Expand Up @@ -464,15 +466,15 @@ object BashWrapper {
val storeStr =
s"""ViashParseArgumentValue "${param.name}" "${param.VIASH_PAR}" "${param.multiple}" "$$1""""

val (begin, end) =
val (begin, mid, end) =
if (param.multiple && param.direction == Input) {
("while", "done")
("while", "do", "done")
} else {
("if", "fi")
("if", "then", "fi")
}

s"""# processing positional values for '${param.name}'
|${begin} [[ $$# -gt 0 ]]; do
|${begin} [[ $$# -gt 0 ]]; ${mid}
| ${storeStr}
| shift 1
|${end}""".stripMargin
Expand Down Expand Up @@ -926,7 +928,7 @@ object BashWrapper {
private def generateWorkDir(argsMetaAndDeps: Map[String, List[Argument[_]]]): BashWrapperMods = {
def renderStrs = argsMetaAndDeps.map{case (key, args) =>
def renderYamlStrs = args.map(arg => {
s"""ViashRenderYamlKeyValue '${arg.name}' '${arg.`type`}' "${arg.multiple}" "$${${arg.VIASH_PAR}:-UNDEFINED}" >> "$$VIASH_WORK_PARAMS""""
s"""ViashRenderYamlKeyValue '${arg.plainName}' '${arg.`type`}' "${arg.multiple}" "$${${arg.VIASH_PAR}:-UNDEFINED}" >> "$$VIASH_WORK_PARAMS""""
})
s"""echo '${key}:' >> "$$VIASH_WORK_PARAMS"
|${renderYamlStrs.mkString("\n")}""".stripMargin
Expand Down

0 comments on commit 921fa8b

Please sign in to comment.