Files
herolib/lib/data/paramsparser/params_exists.v
2024-12-25 09:23:31 +01:00

32 lines
760 B
V

module paramsparser
// check if kwarg exist
// line:
// arg1 arg2 color:red priority:'incredible' description:'with spaces, lets see if ok
// arg1 is an arg
// description is a kwarg
pub fn (params &Params) exists(key_ string) bool {
key := key_.to_lower().trim_space()
for p in params.params {
if p.key == key {
return true
}
}
return false
}
// check if arg exist (arg is just a value in the string e.g. red, not value:something)
// line:
// arg1 arg2 color:red priority:'incredible' description:'with spaces, lets see if ok
// arg1 is an arg
// description is a kwarg
pub fn (params &Params) exists_arg(key_ string) bool {
key := key_.to_lower().trim_space()
for p in params.args {
if p == key {
return true
}
}
return false
}