update all code after version update

This commit is contained in:
Sebastian Thiel
2020-07-10 09:41:44 +08:00
parent c949124df5
commit d1ffa68287
1798 changed files with 692798 additions and 59942 deletions

View File

@@ -402,11 +402,11 @@ pub fn input_mime_from_opts(mime: &str, err: &mut InvalidOptionsError) -> Option
}
}
pub fn writer_from_opts(arg: Option<&str>) -> Result<Box<Write>, io::Error> {
pub fn writer_from_opts(arg: Option<&str>) -> Result<Box<dyn Write>, io::Error> {
let f = arg.unwrap_or("-");
match f {
"-" => Ok(Box::new(stdout())),
_ => match fs::OpenOptions::new().create(true).write(true).open(f) {
_ => match fs::OpenOptions::new().create(true).truncate(true).write(true).open(f) {
Ok(f) => Ok(Box::new(f)),
Err(io_err) => Err(io_err),
},
@@ -488,7 +488,7 @@ impl TokenStorage for JsonTokenStorage {
}
}
Some(token) => {
match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) {
match fs::OpenOptions::new().create(true).write(true).truncate(true).open(&self.path(scope_hash)) {
Ok(mut f) => {
match json::to_writer_pretty(&mut f, &token) {
Ok(_) => Ok(()),
@@ -700,7 +700,7 @@ pub struct InvalidOptionsError {
impl fmt::Display for InvalidOptionsError {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
for issue in &self.issues {
try!(issue.fmt(f));
issue.fmt(f)?;
}
Ok(())
}
@@ -769,6 +769,7 @@ pub fn application_secret_from_directory(dir: &str,
err = match fs::OpenOptions::new()
.create(true)
.write(true)
.truncate(true)
.open(&secret_path) {
Err(cfe) => cfe,
Ok(mut f) => {

View File

@@ -163,10 +163,15 @@ impl<'n> Engine<'n> {
"document-style.page-size.width.unit" => Some(("documentStyle.pageSize.width.unit", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
"document-style.page-size.height.magnitude" => Some(("documentStyle.pageSize.height.magnitude", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
"document-style.page-size.height.unit" => Some(("documentStyle.pageSize.height.unit", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
"document-style.default-header-id" => Some(("documentStyle.defaultHeaderId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
"document-style.margin-bottom.magnitude" => Some(("documentStyle.marginBottom.magnitude", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
"document-style.margin-bottom.unit" => Some(("documentStyle.marginBottom.unit", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
"document-style.default-header-id" => Some(("documentStyle.defaultHeaderId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
"document-style.margin-header.magnitude" => Some(("documentStyle.marginHeader.magnitude", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
"document-style.margin-header.unit" => Some(("documentStyle.marginHeader.unit", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
"document-style.use-custom-header-footer-margins" => Some(("documentStyle.useCustomHeaderFooterMargins", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
"document-style.first-page-header-id" => Some(("documentStyle.firstPageHeaderId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
"document-style.margin-footer.magnitude" => Some(("documentStyle.marginFooter.magnitude", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
"document-style.margin-footer.unit" => Some(("documentStyle.marginFooter.unit", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
"document-style.even-page-header-id" => Some(("documentStyle.evenPageHeaderId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
"document-style.use-first-page-header-footer" => Some(("documentStyle.useFirstPageHeaderFooter", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
"document-style.margin-left.magnitude" => Some(("documentStyle.marginLeft.magnitude", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
@@ -184,7 +189,7 @@ impl<'n> Engine<'n> {
"document-id" => Some(("documentId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
"title" => Some(("title", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
_ => {
let suggestion = FieldCursor::did_you_mean(key, &vec!["background", "blue", "color", "default-footer-id", "default-header-id", "document-id", "document-style", "even-page-footer-id", "even-page-header-id", "first-page-footer-id", "first-page-header-id", "green", "height", "magnitude", "margin-bottom", "margin-left", "margin-right", "margin-top", "page-number-start", "page-size", "red", "revision-id", "rgb-color", "suggestions-view-mode", "title", "unit", "use-even-page-header-footer", "use-first-page-header-footer", "width"]);
let suggestion = FieldCursor::did_you_mean(key, &vec!["background", "blue", "color", "default-footer-id", "default-header-id", "document-id", "document-style", "even-page-footer-id", "even-page-header-id", "first-page-footer-id", "first-page-header-id", "green", "height", "magnitude", "margin-bottom", "margin-footer", "margin-header", "margin-left", "margin-right", "margin-top", "page-number-start", "page-size", "red", "revision-id", "rgb-color", "suggestions-view-mode", "title", "unit", "use-custom-header-footer-margins", "use-even-page-header-footer", "use-first-page-header-footer", "width"]);
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
None
}
@@ -509,7 +514,7 @@ fn main() {
let mut app = App::new("docs1")
.author("Sebastian Thiel <byronimo@gmail.com>")
.version("1.0.10+20190627")
.version("1.0.14+20200706")
.about("Reads and writes Google Docs documents.")
.after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_docs1_cli")
.arg(Arg::with_name("url")