mirror of
https://github.com/Tilo-K/pastebin-cli.git
synced 2026-01-08 07:51:02 +00:00
Clearing Keys + README
This commit is contained in:
41
Cargo.lock
generated
41
Cargo.lock
generated
@@ -612,12 +612,6 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "numtoa"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef"
|
||||
|
||||
[[package]]
|
||||
name = "object"
|
||||
version = "0.32.1"
|
||||
@@ -695,7 +689,7 @@ checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"redox_syscall 0.3.5",
|
||||
"redox_syscall",
|
||||
"smallvec",
|
||||
"windows-targets",
|
||||
]
|
||||
@@ -712,7 +706,6 @@ dependencies = [
|
||||
"reqwest",
|
||||
"rpassword",
|
||||
"serde",
|
||||
"termion",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
@@ -768,15 +761,6 @@ dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.2.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.3.5"
|
||||
@@ -786,15 +770,6 @@ dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_termios"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8440d8acb4fd3d277125b4bd01a6f38aee8d814b3b5fc09b3f2b825d37d3fe8f"
|
||||
dependencies = [
|
||||
"redox_syscall 0.2.16",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "reqwest"
|
||||
version = "0.11.22"
|
||||
@@ -1050,23 +1025,11 @@ checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"fastrand",
|
||||
"redox_syscall 0.3.5",
|
||||
"redox_syscall",
|
||||
"rustix",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "termion"
|
||||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "659c1f379f3408c7e5e84c7d0da6d93404e3800b6b9d063ba24436419302ec90"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"numtoa",
|
||||
"redox_syscall 0.2.16",
|
||||
"redox_termios",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tinyvec"
|
||||
version = "1.6.0"
|
||||
|
||||
@@ -14,5 +14,4 @@ quick-xml = { version = "0.31.0", features = ["serde", "serialize"] }
|
||||
reqwest = { version = "0.11.22", features = ["json"] }
|
||||
rpassword = "7.2.0"
|
||||
serde = { version = "1.0.189", features = ["serde_derive", "derive"] }
|
||||
termion = "2.0.1"
|
||||
tokio = { version = "1.33.0", features = ["full"] }
|
||||
|
||||
98
README.md
Normal file
98
README.md
Normal file
@@ -0,0 +1,98 @@
|
||||
<div align="center">
|
||||
<h1 align="center">
|
||||
<img src="https://upload.wikimedia.org/wikipedia/en/3/35/Pastebin.com_logo.png" width="100" />
|
||||
<br>PASTEBIN-CLI</h1>
|
||||
<h3>◦ A simple CLI to use pastebin in your terminal</h3>
|
||||
<h3>◦ Developed with the software and tools below.</h3>
|
||||
|
||||
<p align="center">
|
||||
<img src="https://img.shields.io/badge/OpenSSL-721412.svg?style=flat-square&logo=OpenSSL&logoColor=white" alt="OpenSSL" />
|
||||
<img src="https://img.shields.io/badge/Rust-000000.svg?style=flat-square&logo=Rust&logoColor=white" alt="Rust" />
|
||||
<img src="https://img.shields.io/badge/Hyper-000000.svg?style=flat-square&logo=Hyper&logoColor=white" alt="Hyper" />
|
||||
</p>
|
||||
|
||||
<img src="https://img.shields.io/github/last-commit/Tilo-K/pastebin-cli?style=flat-square&color=5D6D7E" alt="git-last-commit" />
|
||||
<img src="https://img.shields.io/github/commit-activity/m/Tilo-K/pastebin-cli?style=flat-square&color=5D6D7E" alt="GitHub commit activity" />
|
||||
<img src="https://img.shields.io/github/languages/top/Tilo-K/pastebin-cli?style=flat-square&color=5D6D7E" alt="GitHub top language" />
|
||||
</div>
|
||||
|
||||
---
|
||||
|
||||
## 📖 Table of Contents
|
||||
- [📖 Table of Contents](#-table-of-contents)
|
||||
- [📍 Overview](#-overview)
|
||||
- [📦 Features](#-features)
|
||||
- [📂 repository Structure](#-repository-structure)
|
||||
- [⚙️ Modules](#modules)
|
||||
- [🚀 Getting Started](#-getting-started)
|
||||
- [🔧 Installation](#-installation)
|
||||
- [🤖 Running pastebin-cli](#-running-pastebin-cli)
|
||||
|
||||
---
|
||||
|
||||
## 📦 Features
|
||||
|
||||
- Creating new pastes
|
||||
- Reading pastes
|
||||
- Deleting pastes
|
||||
|
||||
---
|
||||
|
||||
|
||||
## 📂 Repository Structure
|
||||
|
||||
```sh
|
||||
└── pastebin-cli/
|
||||
├── Cargo.lock
|
||||
├── Cargo.toml
|
||||
└── src/
|
||||
├── keys.rs
|
||||
├── main.rs
|
||||
└── pastebin.rs
|
||||
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Getting Started
|
||||
|
||||
### 🔧 Installation
|
||||
```sh
|
||||
cargo install pastebin-cli
|
||||
```
|
||||
|
||||
### 🔧 Installation via Source Code
|
||||
|
||||
1. Clone the pastebin-cli repository:
|
||||
```sh
|
||||
git clone https://github.com/Tilo-K/pastebin-cli
|
||||
```
|
||||
|
||||
2. Change to the project directory:
|
||||
```sh
|
||||
cd pastebin-cli
|
||||
```
|
||||
|
||||
3. Install the dependencies:
|
||||
```sh
|
||||
cargo install .
|
||||
```
|
||||
|
||||
### 🤖 Running pastebin-cli
|
||||
|
||||
```sh
|
||||
pastebin-cli
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🤝 Contributing
|
||||
|
||||
Contributions are welcome! Here are several ways you can contribute:
|
||||
|
||||
- **[Submit Pull Requests](https://github.com/Tilo-K/pastebin-cli/blob/main/CONTRIBUTING.md)**: Review open PRs, and submit your own PRs.
|
||||
- **[Join the Discussions](https://github.com/Tilo-K/pastebin-cli/discussions)**: Share your insights, provide feedback, or ask questions.
|
||||
- **[Report Issues](https://github.com/Tilo-K/pastebin-cli/issues)**: Submit bugs found or log feature requests for TILO-K.
|
||||
19
src/keys.rs
19
src/keys.rs
@@ -55,7 +55,6 @@ pub async fn get_user_key() {
|
||||
|
||||
if key == "" {
|
||||
let mut username = String::new();
|
||||
let mut password = String::new();
|
||||
|
||||
print!("Username: ");
|
||||
io::stdout().lock().flush().unwrap();
|
||||
@@ -65,7 +64,7 @@ pub async fn get_user_key() {
|
||||
|
||||
print!("Password: ");
|
||||
io::stdout().lock().flush().unwrap();
|
||||
password = read_password().unwrap();
|
||||
let password = read_password().unwrap();
|
||||
|
||||
let key = pastebin::get_user_key(&API_KEY.lock().unwrap(), username, password)
|
||||
.await
|
||||
@@ -79,3 +78,19 @@ pub async fn get_user_key() {
|
||||
|
||||
USER_KEY.lock().unwrap().push_str(&key);
|
||||
}
|
||||
|
||||
pub fn clear_keys() {
|
||||
API_KEY.lock().unwrap().clear();
|
||||
USER_KEY.lock().unwrap().clear();
|
||||
|
||||
let home_dir = match home::home_dir() {
|
||||
Some(path) => path,
|
||||
None => panic!("Impossible to get your home dir!"),
|
||||
};
|
||||
|
||||
let key_file = home_dir.join(".pastebin_key");
|
||||
let user_key_file = home_dir.join(".pastebin_userkey");
|
||||
|
||||
fs::remove_file(key_file).expect("Error removing API KEY file");
|
||||
fs::remove_file(user_key_file).expect("Error removing USER KEY file");
|
||||
}
|
||||
10
src/main.rs
10
src/main.rs
@@ -4,6 +4,7 @@ use clap::{Parser, Subcommand};
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
|
||||
|
||||
mod keys;
|
||||
mod pastebin;
|
||||
|
||||
@@ -19,6 +20,7 @@ enum Action {
|
||||
Create { file_path: std::path::PathBuf },
|
||||
Delete { paste_id: String },
|
||||
List { max_results: Option<u16> },
|
||||
ClearKeys,
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
@@ -32,6 +34,7 @@ async fn main() {
|
||||
Action::Create { file_path } => create(file_path).await,
|
||||
Action::Delete { paste_id } => delete(paste_id).await,
|
||||
Action::List { max_results } => list(max_results).await,
|
||||
Action::ClearKeys => keys::clear_keys(),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -64,12 +67,7 @@ async fn delete(paste_id: String) {
|
||||
println!("{}", resp);
|
||||
}
|
||||
|
||||
async fn edit(paste_id: String, file_path: PathBuf) {
|
||||
todo!("No offical way to do that yet");
|
||||
}
|
||||
|
||||
async fn list(max_results: Option<u16>) {
|
||||
let (x, y) = termion::terminal_size().unwrap();
|
||||
let resp = pastebin::list_pastes(
|
||||
&keys::API_KEY.lock().unwrap(),
|
||||
&keys::USER_KEY.lock().unwrap(),
|
||||
@@ -78,7 +76,7 @@ async fn list(max_results: Option<u16>) {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let line = "-".repeat(((x - 15) / 2).into());
|
||||
let line = "-".repeat(5);
|
||||
println!("{}Top {} pastes{}", line, max_results.unwrap_or(10), line);
|
||||
|
||||
for paste in resp {
|
||||
|
||||
Reference in New Issue
Block a user