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
As a continuation of #8 , the tasks whose CreateTask traited via the derive macro should be able to get values from the command line.
Proposed Method
A new annotation should be added to the CreateTask derive called option. Whether a value is optional, is a flag, and takes multiples values should be determined by the type of the field that's annotated by the option.
In addition, the option annotation should have 2 optional settings, name and parse.
name accepts an alternative name for the flag. Otherwise the name of the field is used.
parse accepts some function to try to parse a &str into type T returned in a Result<T, E>. If not specified, the FromStr::from_str is used if it exists. Otherwise a compile time error will be thrown
Example
The :task task is defined by the TasksReport struct, which could be implemented as so:
As a continuation of #8 , the tasks whose
CreateTask
traited via the derive macro should be able to get values from the command line.Proposed Method
A new annotation should be added to the
CreateTask
derive calledoption
. Whether a value is optional, is a flag, and takes multiples values should be determined by the type of the field that's annotated by the option.In addition, the
option
annotation should have 2 optional settings,name
andparse
.name
accepts an alternative name for the flag. Otherwise the name of the field is used.parse
accepts some function to try to parse a&str
into typeT
returned in aResult<T, E>
. If not specified, theFromStr::from_str
is used if it exists. Otherwise a compile time error will be thrownExample
The
:task
task is defined by theTasksReport
struct, which could be implemented as so:The text was updated successfully, but these errors were encountered: