mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-02-23 15:49:49 +01:00
fix(clap): commit before un-using UploadProtocol
We will try to wait for https://github.com/kbknapp/clap-rs/issues/87 to allow us to use the enumeration instead of strings, as well as an iterator, which will look more idiomatic in the end.
This commit is contained in:
@@ -15,6 +15,8 @@
|
||||
v = v and 'true' or 'false'
|
||||
elif isinstance(v, basestring):
|
||||
v = '"%s"' % v
|
||||
elif isinstance(v, list):
|
||||
v = 'vec![%s]' % ','.join('UploadProtocol::%s' % p.capitalize() for p in v)
|
||||
return 'Some(%s)' % v
|
||||
%>\
|
||||
<%def name="grammar(c)">\
|
||||
@@ -118,6 +120,8 @@ Configuration:
|
||||
None
|
||||
))
|
||||
%>\
|
||||
use cmn::UploadProtocol;
|
||||
|
||||
let mut app = App::new("${util.program_name()}")
|
||||
<%block filter="indent_by(7)">\
|
||||
.author("${', '.join(cargo.authors)}")
|
||||
@@ -161,6 +165,7 @@ let arg_data = [
|
||||
mangle_subcommand(p.name),
|
||||
True,
|
||||
False,
|
||||
None,
|
||||
))
|
||||
# end for each required property
|
||||
|
||||
@@ -171,6 +176,7 @@ let arg_data = [
|
||||
KEY_VALUE_ARG,
|
||||
True,
|
||||
True,
|
||||
None
|
||||
))
|
||||
# end request_value
|
||||
|
||||
@@ -183,7 +189,8 @@ let arg_data = [
|
||||
"Specify which file to upload",
|
||||
"mode",
|
||||
True,
|
||||
True,
|
||||
False,
|
||||
upload_protocols
|
||||
))
|
||||
## args.append('-%s %s %s %s' % (UPLOAD_FLAG, mode, FILE_ARG, MIME_ARG))
|
||||
# end upload handling
|
||||
@@ -195,6 +202,7 @@ let arg_data = [
|
||||
VALUE_ARG,
|
||||
False,
|
||||
True,
|
||||
None
|
||||
))
|
||||
# end paramters
|
||||
|
||||
@@ -205,17 +213,19 @@ let arg_data = [
|
||||
OUT_ARG,
|
||||
False,
|
||||
False,
|
||||
None
|
||||
))
|
||||
# handle output
|
||||
%>\
|
||||
("${mangle_subcommand(method)}", ${rust_optional(mc.m.get('description'))},
|
||||
vec![
|
||||
% for flag, desc, arg_name, required, multi in args:
|
||||
% for flag, desc, arg_name, required, multi, upload_protocols in args:
|
||||
(${rust_optional(arg_name)},
|
||||
${rust_optional(flag)},
|
||||
${rust_optional(desc)},
|
||||
${rust_optional(required)},
|
||||
${rust_optional(multi)}),
|
||||
${rust_optional(multi)},
|
||||
${rust_optional(upload_protocols)}),
|
||||
% if not loop.last:
|
||||
|
||||
% endif
|
||||
@@ -234,7 +244,7 @@ for &(main_command_name, ref subcommands) in &arg_data {
|
||||
if let &Some(desc) = desc {
|
||||
scmd = scmd.about(desc);
|
||||
}
|
||||
for &(ref arg_name, ref flag, ref desc, ref required, ref multi) in args {
|
||||
for &(ref arg_name, ref flag, ref desc, ref required, ref multi, ref protocols) in args {
|
||||
let mut arg = Arg::with_name(match (arg_name, flag) {
|
||||
(&Some(an), _) => an,
|
||||
(_, &Some(f)) => f,
|
||||
@@ -254,6 +264,9 @@ for &(main_command_name, ref subcommands) in &arg_data {
|
||||
}
|
||||
if let &Some(multi) = multi {
|
||||
arg = arg.multiple(multi);
|
||||
}
|
||||
if let &Some(ref protocols) = protocols {
|
||||
|
||||
}
|
||||
scmd = scmd.arg(arg);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
<%
|
||||
hub_type_name = 'api::' + hub_type(c.schemas, util.canonical_name())
|
||||
%>\
|
||||
mod cmn;
|
||||
use cmn::{InvalidOptionsError, CLIError, JsonTokenStorage, arg_from_str, writer_from_opts, parse_kv_arg,
|
||||
input_file_from_opts, input_mime_from_opts, FieldCursor, FieldError};
|
||||
|
||||
|
||||
@@ -27,6 +27,8 @@ use std::env;
|
||||
use std::io::{self, Write};
|
||||
use clap::{App, SubCommand, Arg};
|
||||
|
||||
mod cmn;
|
||||
|
||||
## ${engine.new(c)}\
|
||||
|
||||
fn main() {
|
||||
|
||||
@@ -16,6 +16,22 @@ use std::default::Default;
|
||||
|
||||
const FIELD_SEP: char = '.';
|
||||
|
||||
/// Unused for now, can be used once https://github.com/kbknapp/clap-rs/issues/87
|
||||
/// is available
|
||||
pub enum UploadProtocol {
|
||||
Simple,
|
||||
Resumable,
|
||||
}
|
||||
|
||||
impl AsRef<str> for UploadProtocol {
|
||||
fn as_ref(&self) -> &str {
|
||||
match *self {
|
||||
UploadProtocol::Simple => "simple",
|
||||
UploadProtocol::Resumable => "resumable",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Default)]
|
||||
pub struct FieldCursor(Vec<String>);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user