Compare commits

...

5 commits

Author SHA1 Message Date
LordMZTE fc28712e9f
fix libjens URL
Some checks reported errors
continuous-integration/drone/push Build encountered an error
2022-02-13 23:31:39 +01:00
LordMZTE 0855af438e cli now shows meme id in list and search commands 2022-01-20 22:43:34 +01:00
LordMZTE 676f5713ed fix upload endpoint 2022-01-09 00:40:44 +01:00
LordMZTE 11a22df7ea bump version 2021-12-26 14:38:56 +01:00
LordMZTE 9a4a5c5578 added rand command and aliases 2021-12-26 14:37:50 +01:00
8 changed files with 41 additions and 45 deletions

View file

@ -1,6 +1,4 @@
# v1.1.0
# v1.1.2
## cli
- removed fzf integration
- improved tables
- works with new API!
- fixed upload endpoint

View file

@ -1,6 +1,6 @@
[package]
name = "cli"
version = "1.1.0"
version = "1.1.2"
authors = ["LordMZTE <lord@mzte.de>"]
edition = "2018"
license = "GPL-3.0"
@ -19,17 +19,17 @@ path = "src/main.rs"
anyhow = "1.0.52"
chrono = "0.4.19"
clap = "2.34.0"
clap = "3.0.10"
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://git.tilera.org/LordMZTE/libjens.git", rev = "1.1.0" }
log = "0.4.14"
opener = "0.5.0"
reqwest = { version = "0.11.8", features = ["stream", "multipart"] }
serde_json = "1.0.73"
structopt = "0.3.25"
reqwest = { version = "0.11.9", features = ["stream", "multipart"] }
serde_json = "1.0.75"
structopt = "0.3.26"
term_size = "0.3.2"
tokio = { version = "1.15.0", features = ["macros", "fs", "process", "rt-multi-thread"] }
tokio-util = { version = "0.6.9", features = ["codec"] }

View file

@ -1,5 +1,6 @@
pub mod cats;
pub mod list;
pub mod rand;
pub mod search;
pub mod up;
pub mod users;

21
cli/src/commands/rand.rs Normal file
View file

@ -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(())
}

View file

@ -37,7 +37,7 @@ pub async fn run(
let res = client
.http
.post("https://data.tilera.xyz/api/jensmemes/upload")
.post("https://api.tilera.xyz/jensmemes/v1/upload")
.multipart(
Form::new()
.text("category", category)

View file

@ -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<MemeSorting>,
},
#[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(())

View file

@ -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();
@ -57,7 +28,7 @@ macro_rules! impl_table_header {
impl_table_header!(User, vec!["Name", "ID"]);
impl_table_header!(Category, vec!["Name", "ID"]);
impl_table_header!(Meme, vec!["Link", "Category", "User", "Timestamp"]);
impl_table_header!(Meme, vec!["Link", "Category", "User", "Timestamp", "ID"]);
/// a newtype wrapper to convert libjens types to table rows
pub struct JMTableEntry<T>(pub T);
@ -84,6 +55,7 @@ impl From<JMTableEntry<Meme>> for Row {
.timestamp(e.0.timestamp, 0)
.format("%F %R")
.to_string(),
e.0.id,
]
.into()
}

View file

@ -16,6 +16,6 @@ path = "src/main.rs"
[dependencies]
anyhow = "1.0.40"
druid = "0.7.0"
libjens = { git = "https://tilera.xyz/git/LordMZTE/libjens.git", rev = "d4a8b3" }
libjens = { git = "https://git.tilera.org/LordMZTE/libjens.git", rev = "d4a8b3" }
reqwest = "0.10"
tokio = { version = "0.2.23", features = ["macros"] }