Skip to content

Commit 981f7e9

Browse files
committed
Relaxed macro ordering rules for help text to match documented behavior
1 parent fc82d4c commit 981f7e9

File tree

3 files changed

+4
-24
lines changed

3 files changed

+4
-24
lines changed

src/argsparsing.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ end
100100
Convert string to Number type with parse or other type with direct conversion.
101101
Quit program if s is nothing or conversion fails.
102102
"""
103-
function _converttype!(::Type{T}, s::Union{AbstractString, Nothing}, name::String)::T where T
103+
function _converttype!(::Type{T}, s::Union{String, Nothing}, name::String)::T where T
104104
if isnothing(s)
105105
_quit_try_help("Argument $name missing")
106106
end

src/handleast.jl

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ Enforce argument declaration ordering:
1515
Throw `ArgumentError` if ordering violates this rule.
1616
"""
1717
function _validateorder(block::Expr)
18-
encountered_description = false
19-
encountered_argument = false
2018
encountered_positional = false
2119
encoundered_optional_positional = false
2220

@@ -26,30 +24,13 @@ function _validateorder(block::Expr)
2624
# Fix namespace issues
2725
macroname::Symbol = _get_macroname(arg)
2826

29-
if macroname == usage_symbol
30-
if encountered_description || encountered_argument
31-
throw(ArgumentError(
32-
"Usage must be stated before description or arguments.\nFrom: $arg"
33-
))
34-
end
35-
elseif macroname == description_symbol
36-
encountered_description = true
37-
38-
if encountered_argument
39-
throw(ArgumentError(
40-
"Description must be stated before any arguments.\nFrom: $arg"
41-
))
42-
end
43-
elseif macroname in flagged_symbols
44-
encountered_argument = true
45-
27+
if macroname in flagged_symbols
4628
if encountered_positional
4729
throw(ArgumentError(
4830
"Positional arguments must be declared after all flagged arguments.\nFrom: $arg"
4931
))
5032
end
5133
elseif macroname == positional_required_symbol
52-
encountered_argument = true
5334
encountered_positional = true
5435

5536
if encoundered_optional_positional
@@ -58,7 +39,6 @@ function _validateorder(block::Expr)
5839
))
5940
end
6041
elseif macroname in positional_optional_symbols
61-
encountered_argument = true
6242
encountered_positional = true
6343
encoundered_optional_positional = true
6444
end

src/macros.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ macro argtest(argname::Symbol, func::Union{Symbol, Expr}, desc::Union{String, No
299299
end
300300

301301
"""
302-
@allowextraargs
302+
@allowextraarguments
303303
304304
Disables the default behavior of printing a message and exiting
305305
the program when not all values in `ARGS` could be assigned to
@@ -311,7 +311,7 @@ Must be used in `@beginarguments begin ... end` block
311311
```julia
312312
@beginarguments begin
313313
...
314-
@allowextraargs
314+
@allowextraarguments
315315
end
316316
```
317317
"""

0 commit comments

Comments
 (0)