You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is currently a limitation to how optional commands are done: you cant be sure whether a parameter was provided or that the user just gave the null value as an argument.
This is not unfixable, and I believe something similar to rust's Option<> type might be a way to solve this.
I have already implemented something like this in a library of my own: https://github.com/AndreasHGK/go-interactions and, while not the cleanest implementation, it does seem to work.
A command with an optional parameter would look like this:
typeMyCommandstruct {
RequiredParamstringOptionalParam cmd.Optional[string]
}
func (mMyCommand) Run(...) {
optionalString, ok:=m.OptionalParam.Read()
alsoOptionalString:=m.OptionalParam.ReadOrDefault("this is a default string")
}
Even if this is implemented, the old way of doing commands could technically still be supported but I am not sure if that is such a good idea, and DF is in alpha anyway.
The text was updated successfully, but these errors were encountered:
There is currently a limitation to how optional commands are done: you cant be sure whether a parameter was provided or that the user just gave the null value as an argument.
This is not unfixable, and I believe something similar to rust's Option<> type might be a way to solve this.
I have already implemented something like this in a library of my own: https://github.com/AndreasHGK/go-interactions and, while not the cleanest implementation, it does seem to work.
A command with an optional parameter would look like this:
Even if this is implemented, the old way of doing commands could technically still be supported but I am not sure if that is such a good idea, and DF is in alpha anyway.
The text was updated successfully, but these errors were encountered: