Skip to content

Commit

Permalink
Support new option type "nonNegativeInteger"
Browse files Browse the repository at this point in the history
  • Loading branch information
bertfrees committed Jan 16, 2024
1 parent 8e98134 commit a5853b1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
15 changes: 15 additions & 0 deletions cli/scripts.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,8 @@ func optionTypeToString(optionType pipeline.DataType, optionName string, default
}
case pipeline.XsInteger:
return italic("INTEGER")
case pipeline.XsNonNegativeInteger:
return italic("NON-NEGATIVE-INTEGER")
case pipeline.Choice:
var choices []string
for _, value := range t.Values {
Expand Down Expand Up @@ -378,6 +380,12 @@ func optionTypeToDetailedHelp(optionType pipeline.DataType) string {
} else {
help += "An _INTEGER_"
}
case pipeline.XsNonNegativeInteger:
if t.Documentation != "" {
help += t.Documentation
} else {
help += "An non-negative _INTEGER_"
}
case pipeline.Choice:
help += "One of the following:\n"
for _, value := range t.Values {
Expand Down Expand Up @@ -506,6 +514,13 @@ func validateOption(value string, optionType pipeline.DataType, link *PipelineLi
}
case pipeline.XsInteger:
_, err = strconv.ParseInt(value, 0, 0)
case pipeline.XsNonNegativeInteger:
var i int64
i, err = strconv.ParseInt(value, 0, 0)
if (i < 0) {
err = errors.New("does not match " + uncolor(optionTypeToString(t, "", "") + ": value is negative"))
return
}
case pipeline.XsAnyURI:
// _, err = url.Parse(value)
case pipeline.AnyFileURI:
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ require (
github.com/bertfrees/go-subcommand v0.0.0-20230119135135-b5e2f5321a24
github.com/capitancambio/chalk v0.0.0-20160127153406-9dc2af224a17
github.com/capitancambio/restclient v0.0.0-20150219172137-547c7b5e0857
github.com/daisy/pipeline-clientlib-go v0.0.0-20200427151931-aad11eb63a65
// go get github.com/daisy/pipeline-clientlib-go@be58359f0d
github.com/daisy/pipeline-clientlib-go v0.0.0-20231222112022-be58359f0dc7
github.com/hashicorp/go-version v1.0.0
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0
github.com/mattn/goveralls v0.0.11
Expand Down
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ github.com/capitancambio/restclient v0.0.0-20150219172137-547c7b5e0857 h1:JjwRXa
github.com/capitancambio/restclient v0.0.0-20150219172137-547c7b5e0857/go.mod h1:vKGyQZIyL/Ryo5QkEXw1xQIaLiJ/h/wionfFdXLc+5o=
github.com/daisy/pipeline-clientlib-go v0.0.0-20200427151931-aad11eb63a65 h1:9/5fuP+lIM7KgFs3aMInV8LABZIZH2cjn/lUr2WNxaM=
github.com/daisy/pipeline-clientlib-go v0.0.0-20200427151931-aad11eb63a65/go.mod h1:EqAuNzs3I84oUiMMlo787kGYRaNKozEPMfThpfj+sW8=
github.com/daisy/pipeline-clientlib-go v0.0.0-20231222103214-f83d7b8bf58f h1:0NlVgoyQ4+HnTspaFKokVCGII/LglfUyVv1ZLVVGGeg=
github.com/daisy/pipeline-clientlib-go v0.0.0-20231222103214-f83d7b8bf58f/go.mod h1:EqAuNzs3I84oUiMMlo787kGYRaNKozEPMfThpfj+sW8=
github.com/daisy/pipeline-clientlib-go v0.0.0-20231222110436-b4071cde0d7f h1:RpHcpLJLnxzxYTOlTbHbJR4a4YpijJzfAyU2BUKH7LE=
github.com/daisy/pipeline-clientlib-go v0.0.0-20231222110436-b4071cde0d7f/go.mod h1:EqAuNzs3I84oUiMMlo787kGYRaNKozEPMfThpfj+sW8=
github.com/daisy/pipeline-clientlib-go v0.0.0-20231222112022-be58359f0dc7 h1:7UrPVu10K/PzN7YYmF7hYpzrqklTovHpLEWjQBK8U0s=
github.com/daisy/pipeline-clientlib-go v0.0.0-20231222112022-be58359f0dc7/go.mod h1:EqAuNzs3I84oUiMMlo787kGYRaNKozEPMfThpfj+sW8=
github.com/hashicorp/go-version v1.0.0 h1:21MVWPKDphxa7ineQQTrCU5brh7OuVVAzGOCnnCPtE8=
github.com/hashicorp/go-version v1.0.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 h1:iQTw/8FWTuc7uiaSepXwyf3o52HaUYcV+Tu66S3F5GA=
Expand Down

0 comments on commit a5853b1

Please sign in to comment.