Parameters.jl
Parameters.jl copied to clipboard
integration with ArgParse
Hi,
this is a feature request for the integration of Params and https://github.com/carlobaldassi/ArgParse.jl. It would be nice to be able to define an ArgParse table from a @with_kw
struct. My macro-fu is next to zero, but I think most of the machinery needed is already part of @with_kw
, this is why I'm opening the issue here.
With this feature, it would be very easy to create julia code that can be either be included or used as a script. This is the kind of interface I have in mind:
using Parameters, ArgParse
@with_kw struct Params
a::Int
b::String = 2
c::Bool = true # comments could become helpstrings.
end
main(; kws...) = main(Params(; kws...)) # just keywords convenience interface
function main(prms::Params)
....
end
if abspath(PROGRAM_FILE) == @__FILE__
# executing as a script: julia myfile.jl
s = ArgParseSettings()
@add_arg_table! s Params
prms = parse_args(ARGS, s) # return a Params object
main(prms)
end
@mauro3 do you think this is feasible / worth having? pinging also @carlobaldassi
I second this thought. It'd be great to have such interface
This interests me also. I' m looking for something like python' s Hydra that provides composable model parameter configurations.
I fourth this! This would be very useful.