async fn exec(app: Arc<App>) -> Result<()> {
        let query = app.args.value_of("query").unwrap();

        let response = isahc::get_async(format!(
            "https://registry.npmjs.org/-/v1/search?text={}&popularity=1.0",
            query
        ))
        .await
        .unwrap()
        .text()
        .await
        .unwrap();

        let s: Objects = serde_json::from_str(&response).unwrap();

        let mut table = Table::new();

        table
            .load_preset(UTF8_FULL)
            .apply_modifier(UTF8_ROUND_CORNERS)
            .set_content_arrangement(ContentArrangement::DynamicFullWidth);

        table.set_header(vec![
            Cell::new("Name")
                .fg(Color::Green)
                .add_attribute(Attribute::Bold),
            Cell::new("Version")
                .fg(Color::Blue)
                .add_attribute(Attribute::Bold),
            Cell::new("Description")
                .fg(Color::Yellow)
                .add_attribute(Attribute::Bold),
        ]);

        for i in s.objects.iter() {
            let mut description: String = i.package.description.clone();

            if i.package.description.len() > 150 {
                description.truncate(147);
                description = format!("{}...", description);
            }

            table.add_row(vec![
                Cell::new(&i.package.name),
                Cell::new(&i.package.version),
                Cell::new(description),
            ]);
        }

        println!("{}", table);

        Ok(())
    }
/// Execute the `volt search` command
///
/// Search for a package
/// ## Arguments
/// * `error` - Instance of the command (`Arc<App>`)
/// ## Examples
/// ```
/// // Search for a package
/// // .exec() is an async call so you need to await it
/// Search.exec(app).await;
/// ```
/// ## Returns
/// * `Result<()>`
Execute the `volt search` command
Search for a package
Execute the ` volt search ` command Search for a package
async fn exec(app: Arc<App>) -> Result<()> {
        let query = app.args.value_of("query").unwrap();
        let response = isahc::get_async(format!(
            "https://registry.npmjs.org/-/v1/search?text={}&popularity=1.0",
            query
        ))
        .await
        .unwrap()
        .text()
        .await
        .unwrap();
        let s: Objects = serde_json::from_str(&response).unwrap();
        let mut table = Table::new();
        table
            .load_preset(UTF8_FULL)
            .apply_modifier(UTF8_ROUND_CORNERS)
            .set_content_arrangement(ContentArrangement::DynamicFullWidth);
        table.set_header(vec![
            Cell::new("Name")
                .fg(Color::Green)
                .add_attribute(Attribute::Bold),
            Cell::new("Version")
                .fg(Color::Blue)
                .add_attribute(Attribute::Bold),
            Cell::new("Description")
                .fg(Color::Yellow)
                .add_attribute(Attribute::Bold),
        ]);
        for i in s.objects.iter() {
            let mut description: String = i.package.description.clone();
            if i.package.description.len() > 150 {
                description.truncate(147);
                description = format!("{}...", description);
            }
            table.add_row(vec![
                Cell::new(&i.package.name),
                Cell::new(&i.package.version),
                Cell::new(description),
            ]);
        }
        println!("{}", table);
        Ok(())
    }
async fn exec ( app : Arc < App > ) -> Result < ( ) > { let query = app . args . value_of ( " " ) . unwrap ( ) ; let response = isahc :: get_async ( format ! ( " " query ) ) . await . unwrap ( ) . text ( ) . await . unwrap ( ) ; let s : Objects = serde_json :: from_str ( & response ) . unwrap ( ) ; let mut table = Table :: new ( ) ; table . load_preset ( UTF8_FULL ) . apply_modifier ( UTF8_ROUND_CORNERS ) . set_content_arrangement ( ContentArrangement :: DynamicFullWidth ) ; table . set_header ( vec ! [ Cell new ( " " ) fg ( Color Green ) add_attribute ( Attribute Bold ) Cell new ( " " ) fg ( Color Blue ) add_attribute ( Attribute Bold ) Cell new ( " " ) fg ( Color Yellow ) add_attribute ( Attribute Bold ) ] ) ; for i in s . objects . iter ( ) { let mut description : String = i . package . description . clone ( ) ; if i . package . description . len ( ) > 150 { description . truncate ( 147 ) ; description = format ! ( " " description ) ; } table . add_row ( vec ! [ Cell new ( i package name ) Cell new ( i package version ) Cell new ( description ) ] ) ; } println ! ( " " table ) ; Ok ( ( ) ) }
Execute the `volt search` command
Search for a package
Execute the ` volt search ` command Search for a package
None
app
Arc<App>
examples
```
Search for a package
.exec() is an async call so you need to await it
Search.exec(app).await;
```
` ` ` Search for a package . exec () is an async call so you need to await it Search . exec ( app ) . await ; ` ` `