Skip to content

Commit 8376719

Browse files
authored
Switch to '--if-error'. (#84)
1 parent d3f79f8 commit 8376719

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/cli.toit

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ class OptionInt extends Option:
772772
is-flag: return false
773773

774774
parse str/string --for-help-example/bool=false -> int:
775-
return int.parse str --on-error=:
775+
return int.parse str --if-error=:
776776
throw "Invalid integer value for option '$name': '$str'."
777777

778778
/**
@@ -804,7 +804,7 @@ class OptionPatterns extends Option:
804804
--required=required --hidden=hidden --multi=multi \
805805
--split-commas=split-commas
806806
if default:
807-
parse_ default --on-error=:
807+
parse_ default --if-error=:
808808
throw "Default value of '$name' is not a valid value: $default"
809809

810810
is-flag -> bool: return false
@@ -813,12 +813,12 @@ class OptionPatterns extends Option:
813813
Returns the pattern that matches the given $str in a map with the pattern as key.
814814
*/
815815
parse str/string --for-help-example/bool=false -> any:
816-
return parse_ str --on-error=:
816+
return parse_ str --if-error=:
817817
throw "Invalid value for option '$name': '$str'. Valid values are: $(patterns.join ", ")."
818818

819-
parse_ str/string [--on-error]:
819+
parse_ str/string [--if-error]:
820820
if not str.contains ":" and not str.contains "=":
821-
if not patterns.contains str: on-error.call
821+
if not patterns.contains str: if-error.call
822822
return str
823823

824824
separator-index := str.index-of ":"
@@ -827,7 +827,7 @@ class OptionPatterns extends Option:
827827
key-with-equals := "$key="
828828
key-with-colon := "$key:"
829829
if not (patterns.any: it.starts-with key-with-equals or it.starts-with key-with-colon):
830-
on-error.call
830+
if-error.call
831831

832832
return {
833833
key: str[separator-index + 1..]
@@ -867,7 +867,7 @@ class OptionUuid extends Option:
867867
type -> string: return "uuid"
868868

869869
parse str/string --for-help-example/bool=false -> Uuid:
870-
return Uuid.parse str --on-error=:
870+
return Uuid.parse str --if-error=:
871871
throw "Invalid value for option '$name': '$str'. Expected a UUID."
872872

873873

0 commit comments

Comments
 (0)