1 Commits

Author SHA1 Message Date
113fc9db80 chore: upgrade versions 2025-05-16 21:54:06 +02:00
4 changed files with 11 additions and 31 deletions

View File

@@ -40,7 +40,7 @@ permissions:
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
- '**[0-9]+.[0-9]+.[0-9]+*'
pull_request:
jobs:

2
Cargo.lock generated
View File

@@ -746,7 +746,7 @@ dependencies = [
[[package]]
name = "pastebin-cli"
version = "0.1.7"
version = "0.1.5"
dependencies = [
"anyhow",
"chrono",

View File

@@ -1,6 +1,6 @@
[package]
name = "pastebin-cli"
version = "0.1.8"
version = "0.1.5"
edition = "2021"
description = "A simple CLI for pastebin.com"
authors = ["Tilo K"]
@@ -41,12 +41,7 @@ ci = "github"
# The installers to generate for each app
installers = ["shell", "powershell", "npm", "homebrew", "msi"]
# Target platforms to build apps for (Rust target-triple syntax)
targets = [
"aarch64-apple-darwin",
"x86_64-apple-darwin",
"x86_64-unknown-linux-gnu",
"x86_64-pc-windows-msvc",
]
targets = ["aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-pc-windows-msvc"]
# The archive format to use for windows builds (defaults .zip)
windows-archive = ".tar.gz"
# The archive format to use for non-windows builds (defaults .tar.xz)
@@ -58,5 +53,4 @@ pr-run-mode = "plan"
# Whether to install an updater program
install-updater = true
allow-dirty = ["ci"]
allow-dirty = ["ci"]
allow-dirty = ["ci"]

View File

@@ -1,8 +1,10 @@
use chrono::prelude::*;
use chrono::DateTime;
use clap::{Parser, Subcommand};
use std::fs;
use std::path::PathBuf;
mod keys;
mod pastebin;
@@ -77,33 +79,17 @@ async fn list(max_results: Option<u16>) {
let line = "-".repeat(5);
println!("{}Top {} pastes{}", line, max_results.unwrap_or(10), line);
let mut max_length = 8;
let max = resp.iter().map(|paste| paste.paste_title.len()).max();
if max.is_some() {
if max.unwrap() > max_length {
max_length = max.unwrap();
}
}
for paste in resp {
let mut title = paste.paste_title;
if title == "" {
title = "Untitled".to_owned();
}
title = pad_string(&title, max_length);
let naive = NaiveDateTime::from_timestamp_opt(paste.paste_date.into(), 0).unwrap();
let datetime = DateTime::from_timestamp(paste.paste_date.into(), 0).unwrap();
let formatted_date = datetime.format("%Y-%m-%d %H:%M:%S");
let datetime: DateTime<Utc> = DateTime::from_utc(naive, Utc);
let newdate = datetime.format("%Y-%m-%d %H:%M:%S");
println!("{}\t{}\t{}", title, formatted_date, paste.paste_url);
println!("{}\t{}\t{}", title, newdate, paste.paste_url);
}
}
fn pad_string(s: &str, length: usize) -> String {
let mut s = s.to_owned();
while s.len() < length {
s.push(' ');
}
s
}