Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CreateTask derive macro should also create task options implementation #12

Open
joshradin opened this issue Jul 21, 2022 · 0 comments
Open
Assignees
Labels
enhancement New feature or request

Comments

@joshradin
Copy link
Owner

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:

#[derive(CreateTask)]
pub struct TasksReport {
    #[option]
    all: bool,
    #[option(name = "group")]
    groups: Option<Vec<String>>
}
@joshradin joshradin added this to the Minimum Viable Product milestone Jul 21, 2022
@joshradin joshradin self-assigned this Jul 21, 2022
@joshradin joshradin added the enhancement New feature or request label Jul 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

No branches or pull requests

1 participant