Fli icon indicating copy to clipboard operation
Fli copied to clipboard

Implement Zero value for computation expression.

Open AlexStory opened this issue 2 years ago • 1 comments

Would it be possible to implement the Zero value for the cli computation expression? This is needed for letting other values be added conditionally.

In my current process, I'm trying to add the output logging if the user specifies a log file. and it would allow the following to happen

cli {
    Command "command"
    Arguments ["arg1"; "arg2"]
    
    if logPath.isSome then
        Output logPath.Value
}

AlexStory avatar Apr 29 '24 17:04 AlexStory

Thank you, that looks doable. 😊

CaptnCodr avatar Apr 30 '24 09:04 CaptnCodr

Hey @AlexStory, I was playing around with the Zero function in CEs. Unfortunately, it's not possible to implement it in Fli.

I can offer you another thing where I need to fix something anyways: a condition beforehand or inline: let output = if logPath.isSome then logPath.Value else ""

cli {
    Command "command"
    Arguments ["arg1"; "arg2"]
    Output output // or inline condition
}

What do you think?

CaptnCodr avatar May 28 '24 09:05 CaptnCodr

For my personal case that would work, if Output "" is treated the same as just not having an Output

AlexStory avatar May 28 '24 13:05 AlexStory

Yes, it would be like that.

CaptnCodr avatar May 28 '24 14:05 CaptnCodr

This change has been pushed to Nuget in version v1.111.10. Thank you for your patience. 🙂

CaptnCodr avatar May 31 '24 06:05 CaptnCodr