mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-01-08 12:32:08 +01:00
fix(CLI): request value cursor handling and docs
* now the cursor will only be set permanently if the -r flag is used in 'cursor' mode. In 'cursor=value' mode, the cursor change doesn't persist among the flags. That way, one can easily distinguish between setting the cursor, and setting a field. However, '...sublevel.level=value' will still work as it did previously, yet the cursor change will not persist. * Documentation was adjusted to represent the new cursor style. Fixes #86
This commit is contained in:
@@ -382,16 +382,25 @@ if dry_run {
|
||||
flatten_schema_fields(request_cli_schema, schema_fields, init_fn_map)
|
||||
%>\
|
||||
let mut ${request_prop_name} = api::${request_prop_type}::default();
|
||||
let mut field_name = FieldCursor::default();
|
||||
let mut field_cursor = FieldCursor::default();
|
||||
for kvarg in ${SOPT + arg_ident(KEY_VALUE_ARG)}.iter() {
|
||||
let last_errc = err.issues.len();
|
||||
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
||||
if let Err(field_err) = field_name.set(&*key) {
|
||||
let mut temp_cursor = field_cursor.clone();
|
||||
if let Err(field_err) = temp_cursor.set(&*key) {
|
||||
err.issues.push(field_err);
|
||||
}
|
||||
if value.is_none() {
|
||||
field_cursor = temp_cursor.clone();
|
||||
if err.issues.len() > last_errc {
|
||||
err.issues.remove(last_errc);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
% for name in sorted(init_fn_map.keys()):
|
||||
${init_fn_map[name] | indent_by(4)}
|
||||
% endfor
|
||||
match &field_name.to_string()[..] {
|
||||
match &temp_cursor.to_string()[..] {
|
||||
% for init_call, schema, fe, f in schema_fields:
|
||||
<%
|
||||
ptype = actual_json_type(f[-1][1], fe.actual_property.type)
|
||||
@@ -439,7 +448,7 @@ ${opt_suffix}\
|
||||
},
|
||||
% endfor # each nested field
|
||||
_ => {
|
||||
err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string())));
|
||||
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user