mirror of
https://github.com/kjuulh/dagger-rs.git
synced 2025-08-06 07:23:27 +02:00
feat(sdk): move to &str instead of String and introduce builder.
This will make the api much easier to use, as we can now rely on "" instead of "".into() for normal string values. Introduced builder as well, which makes it much easier to use *Opts, as it can handle the building of that, and get the benefits from String -> &str, as that is currently not allowed for optional values
This commit is contained in:
@@ -5,8 +5,8 @@ use genco::quote;
|
||||
use genco::tokens::quoted;
|
||||
|
||||
use crate::functions::{
|
||||
type_field_has_optional, type_ref_is_list_of_objects, type_ref_is_object, type_ref_is_optional,
|
||||
CommonFunctions,
|
||||
type_field_has_optional, type_ref_is_list, type_ref_is_list_of_objects, type_ref_is_object,
|
||||
type_ref_is_optional, type_ref_is_scalar, CommonFunctions, Scalar,
|
||||
};
|
||||
use crate::utility::OptionExt;
|
||||
|
||||
@@ -66,6 +66,40 @@ fn render_required_args(_funcs: &CommonFunctions, field: &FullTypeFields) -> Opt
|
||||
let n = format_struct_name(&s.input_value.name);
|
||||
let name = &s.input_value.name;
|
||||
|
||||
if type_ref_is_scalar(&s.input_value.type_) {
|
||||
if let Scalar::String =
|
||||
Scalar::from(&*s.input_value.type_.of_type.as_ref().unwrap().clone())
|
||||
{
|
||||
return Some(quote! {
|
||||
query = query.arg($(quoted(name)), $(&n).into());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if type_ref_is_list(&s.input_value.type_) {
|
||||
let inner = *s
|
||||
.input_value
|
||||
.type_
|
||||
.of_type
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.clone()
|
||||
.of_type
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.clone();
|
||||
println!("type: {:?}", inner);
|
||||
if type_ref_is_scalar(&inner) {
|
||||
if let Scalar::String =
|
||||
Scalar::from(&*inner.of_type.as_ref().unwrap().clone())
|
||||
{
|
||||
return Some(quote! {
|
||||
query = query.arg($(quoted(name)), $(&n).into_iter().map(|i| i.into()).collect::<Vec<String>>());
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Some(quote! {
|
||||
query = query.arg($(quoted(name)), $(n));
|
||||
})
|
||||
|
Reference in New Issue
Block a user