diff options
Diffstat (limited to 'src/bin/cli/mod.rs')
-rw-r--r-- | src/bin/cli/mod.rs | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/src/bin/cli/mod.rs b/src/bin/cli/mod.rs index e78a92d..30ad5f6 100644 --- a/src/bin/cli/mod.rs +++ b/src/bin/cli/mod.rs @@ -3,6 +3,7 @@ #![allow(unused)] use anyhow::Result; +use clap::ValueEnum; use log::trace; use serde::Serialize; use std::fmt::Debug; @@ -12,7 +13,7 @@ use std::{collections::HashMap, convert::TryFrom}; use subplot::{Document, EmbeddedFile, Style, SubplotError}; pub fn extract_file<'a>(doc: &'a Document, filename: &str) -> Result<&'a EmbeddedFile> { - for file in doc.files() { + for file in doc.embedded_files() { if file.filename() == filename { return Ok(file); } @@ -26,7 +27,6 @@ pub struct Metadata { title: String, binding_files: Vec<String>, impls: HashMap<String, Vec<String>>, - bibliographies: Vec<String>, scenarios: Vec<String>, files: Vec<String>, } @@ -63,13 +63,6 @@ impl TryFrom<&mut Document> for Metadata { (template.to_string(), filenames) }) .collect(); - let mut bibliographies: Vec<_> = doc - .meta() - .bibliographies() - .into_iter() - .map(|p| filename(Some(p))) - .collect(); - bibliographies.sort_unstable(); let mut scenarios: Vec<_> = doc .scenarios()? .into_iter() @@ -77,7 +70,7 @@ impl TryFrom<&mut Document> for Metadata { .collect(); scenarios.sort_unstable(); let mut files: Vec<_> = doc - .files() + .embedded_files() .iter() .map(|f| f.filename().to_owned()) .collect(); @@ -87,7 +80,6 @@ impl TryFrom<&mut Document> for Metadata { title, binding_files, impls, - bibliographies, scenarios, files, }) @@ -96,7 +88,7 @@ impl TryFrom<&mut Document> for Metadata { impl Metadata { fn write_list(v: &[String], prefix: &str) { - v.iter().for_each(|entry| println!("{}: {}", prefix, entry)) + v.iter().for_each(|entry| println!("{prefix}: {entry}")) } pub fn write_out(&self) { @@ -106,9 +98,8 @@ impl Metadata { let templates: Vec<String> = self.impls.keys().map(String::from).collect(); Self::write_list(&templates, "templates"); for (template, filenames) in self.impls.iter() { - Self::write_list(filenames, &format!("functions[{}]", template)); + Self::write_list(filenames, &format!("functions[{template}]")); } - Self::write_list(&self.bibliographies, "bibliography"); Self::write_list(&self.files, "file"); Self::write_list(&self.scenarios, "scenario"); } @@ -125,7 +116,7 @@ fn filename(name: Option<&Path>) -> String { } } -#[derive(Debug)] +#[derive(Debug, ValueEnum, Clone, Copy)] pub enum OutputFormat { Plain, Json, @@ -138,7 +129,7 @@ impl FromStr for OutputFormat { match s.to_ascii_lowercase().as_ref() { "plain" => Ok(OutputFormat::Plain), "json" => Ok(OutputFormat::Json), - _ => Err(format!("Unknown output format: `{}`", s)), + _ => Err(format!("Unknown output format: `{s}`")), } } } |