Skip to content

Commit

Permalink
fixed configuring new storable
Browse files Browse the repository at this point in the history
  • Loading branch information
louisponet committed Apr 19, 2023
1 parent 2af4946 commit d95cfe2
Showing 1 changed file with 28 additions and 29 deletions.
57 changes: 28 additions & 29 deletions src/client.jl
Original file line number Diff line number Diff line change
Expand Up @@ -341,39 +341,38 @@ function configure!(storable::T, s::Server) where {T<:Storable}
write(f, "\n")
write(f, "########## DOCUMENTATION END #####\n\n\n")
end
InteractiveUtils.edit(tf)
tstr = filter(!isempty, readlines(tf))
i = findfirst(x->occursin("```julia",x), tstr)

parsing_error = false

for (ii, f) in enumerate(configurable_fieldnames(T))
field = getfield(storable, f)
ft = typeof(field)
line = tstr[i+ii]
sline = split(line, "=")
try
if length(sline) > 2
v = Main.eval(Meta.parse(join(sline[2:end], "=")))
else
v = Main.eval(Meta.parse(sline[end]))
parsing_error = true

while parsing_error

parsing_error = false

InteractiveUtils.edit(tf)
tstr = filter(!isempty, readlines(tf))
i = findfirst(x->occursin("```julia",x), tstr)

for (ii, f) in enumerate(configurable_fieldnames(T))
field = getfield(storable, f)
ft = typeof(field)
line = tstr[i+ii]
sline = split(line, "=")
try
if length(sline) > 2
v = Main.eval(Meta.parse(join(sline[2:end], "=")))
else
v = Main.eval(Meta.parse(sline[end]))
end

setfield!(storable, f, v)
catch e
@warn "Failed parsing $(split(tstr[i+ii], "=")[end]) as $ft."
showerror(stdout, e, stacktrace(catch_backtrace()))
parsing_error = true
end

setfield!(storable, f, v)
catch e
@warn "Failed parsing $(split(tstr[i+ii], "=")[end]) as $ft."
showerror(stdout, e, stacktrace(catch_backtrace()))
parsing_error = true
end
end
if parsing_error

@info "There was a parsing error. Please try again by pressing any key to continue...\n"
readline()
return configure!(storable, s)
else
return storable
end
return storable
end

function version(s::Server)
Expand Down

0 comments on commit d95cfe2

Please sign in to comment.