diff --git a/extra/command-line/parser/parser-tests.factor b/extra/command-line/parser/parser-tests.factor index 5444f49c2a5..c2641cdf0c9 100644 --- a/extra/command-line/parser/parser-tests.factor +++ b/extra/command-line/parser/parser-tests.factor @@ -5,6 +5,13 @@ math.parser namespaces sequences tools.test ; IN: command-line.parser.tests +TUPLE: foo ; + +[ + { T{ option { name "--foo" } { type foo } } } + { "--foo" "abcd" } (parse-options) +] [ cannot-convert-value? ] must-fail-with + [ { T{ option { name "--foo" } { required? t } } } { } (parse-options) diff --git a/extra/command-line/parser/parser.factor b/extra/command-line/parser/parser.factor index a05e69bfc99..691b0103cd3 100644 --- a/extra/command-line/parser/parser.factor +++ b/extra/command-line/parser/parser.factor @@ -32,9 +32,8 @@ TUPLE: option name type help variable default convert validate : option-name ( option -- name ) { - [ name>> [ CHAR: - = ] trim-head ] - [ variable>> dup string? [ name>> ] unless ] - } 1|| ; + [ name>> ] [ variable>> dup string? [ name>> ] unless ] + } 1|| [ CHAR: - = ] trim-head ; :: option-#args ( option -- #args ) option #args>> [ option const>> 1 xor ] unless* ; @@ -107,6 +106,7 @@ M: cannot-convert-value error. dup quotation? [ call( str -- val ) ] [ { { f [ ] } + { string [ ] } { object [ [ 1array [ scan-object ] with-lexer ] with-manifest ] } { boolean [ { { [ dup >lower { "t" "true" "1" "on" "y" "yes" } member? ] [ drop t ] }