feat(cli): added some filter flags to GitRepo CLI

This commit is contained in:
Jef Roosens 2022-05-29 21:07:46 +02:00
parent a39c1aa5eb
commit 401e0291e3
Signed by: Jef Roosens
GPG key ID: B75D4F293C7052DB
5 changed files with 77 additions and 22 deletions

View file

@ -30,11 +30,11 @@ pub fn (bl &BuildLog) str() string {
[params]
pub struct BuildLogFilter {
pub mut:
limit u64 = 25
offset u64
repo int
before time.Time
after time.Time
arch string
limit u64 = 25
offset u64
repo int
before time.Time
after time.Time
arch string
exit_codes []string
}

View file

@ -30,7 +30,6 @@ pub fn patch_from_params<T>(mut o T, params map[string]string) ? {
} $else $if field.typ is []string {
o.$(field.name) = params[field.name].split(',')
}
} else if field.attrs.contains('nonull') {
return error('Missing parameter: ${field.name}.')
}
@ -42,7 +41,13 @@ pub fn params_from<T>(o &T) map[string]string {
mut out := map[string]string{}
$for field in T.fields {
out[field.name] = o.$(field.name).str()
$if field.typ is time.Time {
out[field.name] = o.$(field.name).unix_time().str()
} $else $if field.typ is []string {
out[field.name] = o.$(field.name).join(',')
} $else {
out[field.name] = o.$(field.name).str()
}
}
return out
}