currently there's a SudoAction enum, a SudoOptions struct and a validate method in the cli module. ideally, the validate function / method should returned a cooked / sanitized action enum where its variants contain the flags that are valid for that particular action. something like the code block below
pub enum CookedSudoAction {
Help, // no options can be passed here
Run {
flag_user: Option<String>,
flag_group: Option<String>,
// ..
cmnd_args: Vec<String>, // not-empty vector
},
Validate {
// no cmnd_args field here
}
// ...
}
the goal is to discard the fields in SudoOptions that do not apply to a particular action so that when handling a particular "action" later in the pipeline one does not accept an invalid option / flag by mistake. thus validate should consume SudoOptions
one could even add extra validation at this step and represent flag_{user,group} as NameOrId rather than as a string.
currently there's a
SudoAction
enum, aSudoOptions
struct and avalidate
method in thecli
module. ideally, thevalidate
function / method should returned a cooked / sanitized action enum where its variants contain the flags that are valid for that particular action. something like the code block belowthe goal is to discard the fields in
SudoOptions
that do not apply to a particular action so that when handling a particular "action" later in the pipeline one does not accept an invalid option / flag by mistake. thusvalidate
should consumeSudoOptions
one could even add extra validation at this step and represent
flag_{user,group}
asNameOrId
rather than as a string.