Skip to content

Commit

Permalink
release v0.2.1
Browse files Browse the repository at this point in the history
Develop release v0.2.1
  • Loading branch information
josueBarretogit authored Jun 29, 2024
2 parents 53abade + 99f9f5f commit 6a2a377
Show file tree
Hide file tree
Showing 17 changed files with 675 additions and 629 deletions.
37 changes: 26 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[package]
name = "get-blessed"
version = "0.2.0"
version = "0.2.1"
edition = "2021"
authors = ["Josue <[email protected]>"]
readme = "README.md"
homepage = "https://github.com/josueBarretogit/get_blessed_rs"
repository = "https://github.com/josueBarretogit/get_blessed_rs"
description = "Terminal tool to get you the best crates for your rust projects with a few keybindings, curated by blessed.rs"
keywords = ["cli", "command-line", "developer-tools", "dependencies"]
categories = ["utilities", "development-tools" , "command-line", "dependencies"]
keywords = ["cli", "command-line", "developer-tools"]
categories = ["development-tools", "command-line-interface" , "command-line-utilities"]
license = "MIT"
exclude = [
"public/*"
Expand All @@ -17,13 +17,15 @@ exclude = [

[dependencies]
reqwest = { version = "0.12.4" , features = ["json"]}
ratatui = { version = "0.26.3", features = ["all-widgets"] }
ratatui = { version = "0.26.3", features = ["all-widgets", "unstable-widget-ref"] }
color-eyre = "0.6.2"
crossterm = { version = "0.27.0", features = ["event-stream"] }
serde = { version = "1.0.200", features = ["derive"] }
strum = "0.26.2"
strum_macros = "0.26"
open = "5.1.3"
throbber-widgets-tui = "0.5.0"
tokio = { version = "1.37.0", features = ["full"] }
tokio = { version = "1.37.0", features = ["macros", "rt-multi-thread"] }
crates_io_api = "0.11.0"
type_utilities = { version = "0.1.2", features = ["bool"] }
tui-widget-list = "0.9.0"
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,15 @@ them to your rust projects right in your terminal.
## Features


- Check out a crate documentation pressing `<d>` (Opens a tab in your default web browser)
- Check out a crate crates.io page pressing `<c>` (Opens a tab in your default web browser)
- Check out a crate's documentation by pressing `<d>` (Opens a tab in your default web browser)
- Check out a crate's crates.io page by pressing `<c>` (Opens a tab in your default web browser)
- Move between categories with `<Tab>` or `<Shift + Tab>`
- Move up and down with either arrow keys or with `<j>` / `<k>`
- Move up and down with either `<Up>` and `<Down>` arrow keys or with `<j>` / `<k>`
- Select the crate you want in your project by pressing `<s>`
- Select all the crates from a category by pressing `<a>`
- Select a crate with features by pressing `<f>` (Opens a popup where you can select the features with `<s>`)
- Add the selected crates to your rust project by pressing `<Enter>`

![features](./public/features.gif)


- After you are done press `<q>` or `<Esc>` to quit
- Close the application with `<q>` or `<Esc>`

## Installation

Expand Down
Binary file modified public/showcase.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 6 additions & 3 deletions src/backend.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use strum::{Display, EnumIter, FromRepr};

use crate::view::widgets::{CrateItemList, FeatureItemList, ItemListStatus};
use strum::{Display, EnumIter, FromRepr};

///This struct represent the data as seen in the actual page
#[derive(Default, Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub struct Crates {
Expand Down Expand Up @@ -31,7 +31,7 @@ impl From<crate::backend::Table> for Vec<CrateItemList> {
krate.name.clone(),
krate.description.clone(),
ItemListStatus::default(),
krate.features.clone().map(|features| {
krate.features.as_ref().map(|features| {
features
.iter()
.map(|feat| FeatureItemList::new(feat.clone()))
Expand All @@ -40,6 +40,9 @@ impl From<crate::backend::Table> for Vec<CrateItemList> {
));
}
}
items.sort();

items.dedup();

items
}
Expand Down
3 changes: 2 additions & 1 deletion src/content_parser.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::backend::{Categories, CategoriesWithSubCategories, Crates, Table, TableEntry};
use crate::scraper::scraper::Group;
use crate::scraper::Group;


pub mod jsoncontentparser;

Expand Down
10 changes: 4 additions & 6 deletions src/content_parser/jsoncontentparser.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
use crate::{
backend::{Categories, CategoriesWithSubCategories, Table},
scraper::scraper::{scrape_site, CratesData, Group},
scraper::{scrape_site, Group},
};

use super::ContentParser;

#[allow(clippy::struct_field_names)]
#[derive(Debug)]
pub struct JsonContentParser {
pub content: CratesData,

general_crates: Table,
math_crates: Table,
ffi_crates: Table,
Expand Down Expand Up @@ -75,8 +74,7 @@ impl JsonContentParser {
}

Self {
content: page_content,
graphics_crates,
general_crates,
math_crates,
ffi_crates,
cryptography_crates,
Expand All @@ -85,7 +83,7 @@ impl JsonContentParser {
networking_crates,
database_crates,
clis_crates,
general_crates,
graphics_crates,
}
}
}
Expand Down
35 changes: 26 additions & 9 deletions src/dependency_builder.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
/// This module's job is to add de crate or dependencies to the user's project
use std::fmt::Write;
use std::{io, ops::Deref, process::Command};

use std::{io, process::Command};
use crate::view::widgets::{CrateItemList, ItemListStatus};

pub mod dependency_builder;

/// This is the data neccesary to add a crate to the user's project
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub struct CrateToAdd {
pub crate_name: String,
pub features: Option<Vec<String>>,
}

impl Deref for CrateToAdd {
type Target = CrateToAdd;
fn deref(&self) -> &Self::Target {
self
}
}

impl From<CrateItemList> for CrateToAdd {
fn from(value: CrateItemList) -> Self {
Expand All @@ -38,6 +32,29 @@ impl From<CrateItemList> for CrateToAdd {
}
}



impl From<&CrateItemList> for CrateToAdd {
fn from(value: &CrateItemList) -> Self {
Self {
crate_name: value.name.clone(),
features: value.features.as_ref().map(|features| {
features
.iter()
.filter_map(|feature_item| {
if feature_item.status == ItemListStatus::Selected {
Some(feature_item.name.clone())
} else {
None
}
})
.collect()
}),
}
}
}


pub struct DependenciesBuilder {
crates_to_add: Vec<CrateToAdd>,
}
Expand Down
1 change: 0 additions & 1 deletion src/dependency_builder/dependency_builder.rs

This file was deleted.

1 change: 0 additions & 1 deletion src/lib.rs

This file was deleted.

36 changes: 35 additions & 1 deletion src/scraper.rs
Original file line number Diff line number Diff line change
@@ -1 +1,35 @@
pub mod scraper;
use serde::{Deserialize};

#[derive(Deserialize, Debug, Default, Clone)]
pub struct Group {
pub name: String,
pub subgroups: Option<Vec<Group>>,
pub purposes: Option<Vec<Purpose>>,
}

#[derive(Deserialize, Debug, Default, Clone)]
pub struct Purpose {
pub name: String,
pub recommendations: Vec<Recommendation>,
}

#[derive(Deserialize, Debug, Default, Clone)]
pub struct Recommendation {
pub name: String,
pub notes: Option<String>,
}

#[derive(Deserialize, Debug, Default, Clone)]
pub struct CratesData {
pub crate_groups: Vec<Group>,
}

pub async fn scrape_site() -> Result<CratesData, reqwest::Error> {
let response = reqwest::get(
"https://raw.githubusercontent.com/nicoburns/blessed-rs/main/data/crates.json",
)
.await?
.json::<CratesData>()
.await?;
Ok(response)
}
37 changes: 0 additions & 37 deletions src/scraper/scraper.rs

This file was deleted.

Loading

0 comments on commit 6a2a377

Please sign in to comment.