pub async fn view(&mut self, filters: Filters, id: Option<String>) -> color_eyre::Result<()> {
        if self.config.annotation_template.is_none() {
            self.config.set_annotation_template()?;
        }
        let hbs = self.get_handlebars()?;
        if let Some(id) = id {
            let annotation = self
                .api
                .fetch_annotation(&id)
                .await
                .suggestion("Are you sure this is a valid and existing annotation ID?")?;
            let markdown = hbs.render(
                "annotation",
                &AnnotationTemplate::from_annotation(annotation),
            )?;
            bat::PrettyPrinter::new()
                .language("markdown")
                .input_from_bytes(markdown.as_ref())
                .print()
                .unwrap();
            return Ok(());
        }
        let annotations: Vec<Annotation> = self
            .filter_annotations(filters, None)
            .await?
            .into_iter()
            .collect();
        let inputs: Vec<_> = annotations
            .into_iter()
            .map(|annotation| {
                hbs.render(
                    "annotation",
                    &AnnotationTemplate::from_annotation(annotation),
                )
            })
            .collect::<Result<_, _>>()?;
        bat::PrettyPrinter::new()
            .language("markdown")
            .inputs(inputs.iter().map(|i| bat::Input::from_bytes(i.as_bytes())))
            .print()
            .unwrap();
        Ok(())
    }
/// View optionally filtered annotations in the terminal
View optionally filtered annotations in the terminal
View optionally filtered annotations in the terminal
pub async fn view(&mut self, filters: Filters, id: Option<String>) -> color_eyre::Result<()> {
        if self.config.annotation_template.is_none() {
            self.config.set_annotation_template()?;
        }
        let hbs = self.get_handlebars()?;
        if let Some(id) = id {
            let annotation = self
                .api
                .fetch_annotation(&id)
                .await
                .suggestion("Are you sure this is a valid and existing annotation ID?")?;
            let markdown = hbs.render(
                "annotation",
                &AnnotationTemplate::from_annotation(annotation),
            )?;
            bat::PrettyPrinter::new()
                .language("markdown")
                .input_from_bytes(markdown.as_ref())
                .print()
                .unwrap();
            return Ok(());
        }
        let annotations: Vec<Annotation> = self
            .filter_annotations(filters, None)
            .await?
            .into_iter()
            .collect();
        let inputs: Vec<_> = annotations
            .into_iter()
            .map(|annotation| {
                hbs.render(
                    "annotation",
                    &AnnotationTemplate::from_annotation(annotation),
                )
            })
            .collect::<Result<_, _>>()?;
        bat::PrettyPrinter::new()
            .language("markdown")
            .inputs(inputs.iter().map(|i| bat::Input::from_bytes(i.as_bytes())))
            .print()
            .unwrap();
        Ok(())
    }
pub async fn view ( & mut self , filters : Filters , id : Option < String > ) -> color_eyre :: Result < ( ) > { if self . config . annotation_template . is_none ( ) { self . config . set_annotation_template ( ) ? ; } let hbs = self . get_handlebars ( ) ? ; if let Some ( id ) = id { let annotation = self . api . fetch_annotation ( & id ) . await . suggestion ( " " ) ? ; let markdown = hbs . render ( " " , & AnnotationTemplate :: from_annotation ( annotation ) , ) ? ; bat :: PrettyPrinter :: new ( ) . language ( " " ) . input_from_bytes ( markdown . as_ref ( ) ) . print ( ) . unwrap ( ) ; return Ok ( ( ) ) ; } let annotations : Vec < Annotation > = self . filter_annotations ( filters , None ) . await ? . into_iter ( ) . collect ( ) ; let inputs : Vec < _ > = annotations . into_iter ( ) . map ( | annotation | { hbs . render ( " " , & AnnotationTemplate :: from_annotation ( annotation ) , ) } ) . collect :: < Result < _ , _ > > ( ) ? ; bat :: PrettyPrinter :: new ( ) . language ( " " ) . inputs ( inputs . iter ( ) . map ( | i | bat :: Input :: from_bytes ( i . as_bytes ( ) ) ) ) . print ( ) . unwrap ( ) ; Ok ( ( ) ) }
View optionally filtered annotations in the terminal
View optionally filtered annotations in the terminal
&mut self
filters
Filters
id
Option<String>
&mut self
filters
Filters
id
Option<String>