diff --git a/CHANGELOG.md b/CHANGELOG.md index 90e0c23..ceeb9c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,5 @@ -# v1.1.0 +# v1.1.1 ## cli -- removed fzf integration -- improved tables -- works with new API! +- added some command aliases +- added rand command diff --git a/cli/Cargo.toml b/cli/Cargo.toml index bea2e4b..3df7e80 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -24,7 +24,7 @@ comfy-table = "5.0.0" env_logger = "0.9.0" fuzzy-matcher = "0.3.7" indicatif = "0.16.2" -libjens = { git = "https://tilera.xyz/git/LordMZTE/libjens.git", rev = "1.0.1" } +libjens = { git = "https://tilera.xyz/git/LordMZTE/libjens.git", rev = "1.1.0" } log = "0.4.14" opener = "0.5.0" reqwest = { version = "0.11.8", features = ["stream", "multipart"] } diff --git a/cli/src/commands/mod.rs b/cli/src/commands/mod.rs index d4c6d00..e63f2e6 100644 --- a/cli/src/commands/mod.rs +++ b/cli/src/commands/mod.rs @@ -1,5 +1,6 @@ pub mod cats; pub mod list; +pub mod rand; pub mod search; pub mod up; pub mod users; diff --git a/cli/src/commands/rand.rs b/cli/src/commands/rand.rs new file mode 100644 index 0000000..a2c10a8 --- /dev/null +++ b/cli/src/commands/rand.rs @@ -0,0 +1,21 @@ +use anyhow::Result; +use chrono::{Local, TimeZone}; +use libjens::JMClient; + +pub async fn run(client: &JMClient) -> Result<()> { + let meme = client.get_random().await?; + + println!( + "\ +Link: {} +Category: {} +User: {} +Timestamp: {}", + meme.link, + meme.category, + meme.user, + Local.timestamp(meme.timestamp, 0).format("%F %R") + ); + + Ok(()) +} diff --git a/cli/src/main.rs b/cli/src/main.rs index c12c24b..ebf92da 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -39,10 +39,10 @@ enum Cmd { open: bool, }, - #[structopt(about = "lists the available categories")] + #[structopt(about = "lists the available categories", alias = "c")] Cats, - #[structopt(about = "searches for a meme")] + #[structopt(about = "searches for a meme", alias = "s")] Search { query: String, @@ -79,8 +79,11 @@ enum Cmd { sort: Option, }, - #[structopt(about = "Lists all users")] + #[structopt(about = "Lists all users", alias = "u")] Users, + + #[structopt(about = "Gets a random meme", alias = "r")] + Rand, } #[tokio::main] @@ -115,6 +118,7 @@ async fn main() -> Result<()> { sort, } => commands::list::run(&client, category, user, sort).await?, Cmd::Users => commands::users::run(&client).await?, + Cmd::Rand => commands::rand::run(&client).await?, } Ok(()) diff --git a/cli/src/table.rs b/cli/src/table.rs index cbe4cfc..a022f7a 100644 --- a/cli/src/table.rs +++ b/cli/src/table.rs @@ -2,35 +2,6 @@ use chrono::{Local, TimeZone}; use comfy_table::{presets::UTF8_NO_BORDERS, ContentArrangement, Row, Table}; use libjens::api::{Category, Meme, User}; -// pub trait AsTableRow { -// fn as_table_row(&self) -> term_table::row::Row; -//} -// impl AsTableRow for Category { -// fn as_table_row(&self) -> Row<'_> { -// Row::new(vec![TableCell::new(&self.id), TableCell::new(&self.name)]) -// } -//} -// impl AsTableRow for Meme { -// fn as_table_row(&self) -> Row<'_> { -// Row::new(vec![ -// TableCell::new(&self.link), -// TableCell::new(&self.category), -// TableCell::new(&self.user), -// TableCell::new(Local.timestamp(self.timestamp, 0).format("%F -// %R")), TableCell::new(&self.id), -// ]) -// } -//} -// impl AsTableRow for User { -// fn as_table_row(&self) -> Row<'_> { -// Row::new(vec![ -// TableCell::new(&self.name), -// TableCell::new(&self.get_id().map(String::as_ref).unwrap_or("[No -// ID]")), TableCell::new(&self.dayuploads), -// ]) -// } -//} - pub fn list_table() -> Table { let mut table = Table::new();