Properly allow not prompting for fields with defaults
This commit is contained in:
parent
f7743df133
commit
f630f9c3f4
@ -13,8 +13,10 @@ function interactive(::Type{T}) where T <: Plugin
|
|||||||
default = required ? defaultkw(F) : defaultkw(T, v)
|
default = required ? defaultkw(F) : defaultkw(T, v)
|
||||||
kwargs[name] = if applicable(prompt, T, v)
|
kwargs[name] = if applicable(prompt, T, v)
|
||||||
prompt(F, "$T: $(prompt(T, v))", default, required=required)
|
prompt(F, "$T: $(prompt(T, v))", default, required=required)
|
||||||
else
|
elseif required
|
||||||
prompt(F, "$T: Value for field '$name' ($F)", default; required=required)
|
prompt(F, "$T: Value for field '$name' ($F)", default; required=required)
|
||||||
|
else
|
||||||
|
default
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -28,16 +28,13 @@ macro with_defaults(ex::Expr)
|
|||||||
push!(funcs, :(PkgTemplates.prompt(::Type{$T}, ::Val{$name}) = $(esc(prompt))))
|
push!(funcs, :(PkgTemplates.prompt(::Type{$T}, ::Val{$name}) = $(esc(prompt))))
|
||||||
elseif arg.head === :(=)
|
elseif arg.head === :(=)
|
||||||
rhs = arg.args[2]
|
rhs = arg.args[2]
|
||||||
|
name = QuoteNode(arg.args[1].args[1])
|
||||||
if iscall(rhs, :<) && iscall(rhs.args[3], :-) # x::T = "foo" <- "prompt"
|
if iscall(rhs, :<) && iscall(rhs.args[3], :-) # x::T = "foo" <- "prompt"
|
||||||
name = QuoteNode(arg.args[1].args[1])
|
|
||||||
prompt = rhs.args[3].args[2]
|
prompt = rhs.args[3].args[2]
|
||||||
default = arg.args[2] = rhs.args[2]
|
push!(funcs, :(PkgTemplates.prompt(::Type{$T}, ::Val{$name}) = $(esc(prompt))))
|
||||||
push!(
|
|
||||||
funcs,
|
|
||||||
:(PkgTemplates.prompt(::Type{$T}, ::Val{$name}) = $(esc(prompt))),
|
|
||||||
:(PkgTemplates.defaultkw(::Type{$T}, ::Val{$name}) = $(esc(default))),
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
default = arg.args[2] = rhs.args[2]
|
||||||
|
push!(funcs, :(PkgTemplates.defaultkw(::Type{$T}, ::Val{$name}) = $(esc(default))))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user