@@ -96,19 +96,12 @@ function _pop_count!(args::Vector{String}, flag::String)::Int
96
96
return initial_arg_length - length (args)
97
97
end
98
98
99
- """
100
- Convert string to Number type with parse or other type with direct conversion.
101
- Quit program if s is nothing or conversion fails.
102
- """
103
- function _converttype! (:: Type{T} , s:: Union{String, Nothing} , name:: String ):: T where T
104
- if isnothing (s)
105
- _quit_try_help (" Argument $name missing" )
106
- end
107
-
99
+ " Convert string to Number type with parse or other type with direct conversion."
100
+ function _converttype! (:: Type{T} , s:: String , name:: String ):: T where T
108
101
try
109
102
if T <: Number
110
- # Allow floating value to be passed to Int argument
111
- return T (parse (Float64, s))
103
+ # Allow floating point value to be passed to Int argument
104
+ return T (parse (Float64, s):: Float64 )
112
105
else
113
106
return T (s)
114
107
end
@@ -117,6 +110,11 @@ function _converttype!(::Type{T}, s::Union{String, Nothing}, name::String)::T wh
117
110
end
118
111
end
119
112
113
+ " Quit program if the value is nothing"
114
+ function _converttype! (:: Type{T} , :: Nothing , name:: String ):: Nothing where T
115
+ _quit_try_help (" Argument $name missing" )
116
+ end
117
+
120
118
" If x is not a string (i.e. literal passed as default) assume direct conversion is possible. Does NOT validate."
121
119
function _converttype! (:: Type{T} , x:: Any , :: String ):: T where T
122
120
return T (x)
0 commit comments