Skip to content
Snippets Groups Projects
Commit 5e24a23a authored by Stephen D's avatar Stephen D
Browse files

Everything important is done

parent 53e9cc01
No related branches found
No related tags found
No related merge requests found
......@@ -11,12 +11,56 @@ dependencies = [
"winapi",
]
[[package]]
name = "autocfg"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
[[package]]
name = "bitflags"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
[[package]]
name = "cfg-if"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
[[package]]
name = "clap"
version = "3.0.0-beta.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4bd1061998a501ee7d4b6d449020df3266ca3124b941ec56cf2005c3779ca142"
dependencies = [
"atty",
"bitflags",
"clap_derive",
"indexmap",
"lazy_static",
"os_str_bytes",
"strsim",
"termcolor",
"textwrap",
"unicode-width",
"vec_map",
]
[[package]]
name = "clap_derive"
version = "3.0.0-beta.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "370f715b81112975b1b69db93e0b56ea4cd4e5002ac43b2da8474106a54096a1"
dependencies = [
"heck",
"proc-macro-error",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "colored"
version = "2.0.0"
......@@ -39,6 +83,21 @@ dependencies = [
"wasi",
]
[[package]]
name = "hashbrown"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00d63df3d41950fb462ed38308eea019113ad1508da725bbedcd0fa5a85ef5f7"
[[package]]
name = "heck"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205"
dependencies = [
"unicode-segmentation",
]
[[package]]
name = "hermit-abi"
version = "0.1.16"
......@@ -48,6 +107,16 @@ dependencies = [
"libc",
]
[[package]]
name = "indexmap"
version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55e2e4c765aa53a0424761bf9f41aa7a6ac1efa87238f59560640e27fca028f2"
dependencies = [
"autocfg",
"hashbrown",
]
[[package]]
name = "lazy_static"
version = "1.4.0"
......@@ -64,16 +133,65 @@ checksum = "f2f96b10ec2560088a8e76961b00d47107b3a625fecb76dedb29ee7ccbf98235"
name = "lolcatrs"
version = "0.1.0"
dependencies = [
"clap",
"colored",
"rand",
]
[[package]]
name = "os_str_bytes"
version = "2.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2ac6fe3538f701e339953a3ebbe4f39941aababa8a3f6964635b24ab526daeac"
[[package]]
name = "ppv-lite86"
version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c36fa947111f5c62a733b652544dd0016a43ce89619538a8ef92724a6f501a20"
[[package]]
name = "proc-macro-error"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
dependencies = [
"proc-macro-error-attr",
"proc-macro2",
"quote",
"syn",
"version_check",
]
[[package]]
name = "proc-macro-error-attr"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
dependencies = [
"proc-macro2",
"quote",
"version_check",
]
[[package]]
name = "proc-macro2"
version = "1.0.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e4b93dba1818d32e781f9d008edd577bab215e83ef50e8a1ddf1ad301b19a09f"
dependencies = [
"unicode-xid",
]
[[package]]
name = "quote"
version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37"
dependencies = [
"proc-macro2",
]
[[package]]
name = "rand"
version = "0.7.3"
......@@ -115,6 +233,71 @@ dependencies = [
"rand_core",
]
[[package]]
name = "strsim"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]]
name = "syn"
version = "1.0.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6690e3e9f692504b941dc6c3b188fd28df054f7fb8469ab40680df52fdcc842b"
dependencies = [
"proc-macro2",
"quote",
"unicode-xid",
]
[[package]]
name = "termcolor"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f"
dependencies = [
"winapi-util",
]
[[package]]
name = "textwrap"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "203008d98caf094106cfaba70acfed15e18ed3ddb7d94e49baec153a2b462789"
dependencies = [
"unicode-width",
]
[[package]]
name = "unicode-segmentation"
version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0"
[[package]]
name = "unicode-width"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3"
[[package]]
name = "unicode-xid"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
[[package]]
name = "vec_map"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
[[package]]
name = "version_check"
version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed"
[[package]]
name = "wasi"
version = "0.9.0+wasi-snapshot-preview1"
......@@ -137,6 +320,15 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
dependencies = [
"winapi",
]
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
......
[package]
name = "lolcatrs"
version = "0.1.0"
authors = ["Stephen <webmaster@scd31.com>"]
authors = ["Stephen <stephen@scd31.com>"]
description = "Like lolcat, but fast"
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
colored = "2.0"
rand = "0.7"
\ No newline at end of file
rand = "0.7"
clap = "3.0.0-beta.2"
\ No newline at end of file
use colored::{ColoredString, Colorize};
use colored::Colorize;
use std::f64::consts;
use std::io::{stdout, Write};
use std::process::exit;
......
use std::io;
use std::process::exit;
use clap::Clap;
use std::fs::File;
use std::io::{stdin, BufRead, BufReader};
mod lol;
///this is a test.
#[derive(Clap)]
#[clap(author, about, version)]
#[clap(
after_help = "Examples:\n\tlolcatrs f - g\tOutput f's contents, then stdin, then g's contents.\n\tfortune | lolcat\tDisplay a rainbow cookie."
)]
struct CmdOpts {
#[clap(short = 'p', long, default_value = "1.0")]
/// Rainbow spread
spread: f64,
/// Rainbow frequency
#[clap(short = 'F', long, default_value = "0.1")]
freq: f64,
/// Rainbow seed, 0 = random
#[clap(short = 'S', long, default_value = "0.0")]
seed: f64,
/// Invert fg and bg
#[clap(short = 'i', long)]
invert: bool,
/// Files to concatenate(`-` for STDIN)
files: Vec<String>,
}
fn read_line() -> Option<(String, usize)> {
let mut input = String::new();
match io::stdin().read_line(&mut input) {
match stdin().read_line(&mut input) {
Ok(n) => Some((input, n)),
_ => None,
}
}
fn main() {
let mut seed: f64 = rand::random::<f64>() * 1_000_000.0;
while let Some((x, n)) = read_line() {
lol::print_rainbow(&x, 0.1, seed, 3.0, true);
if n == 0 {
// EOF
exit(0);
let opts: CmdOpts = CmdOpts::parse();
let mut files = opts.files;
if files.is_empty() {
files.push("-".to_string());
}
let mut seed: f64 = opts.seed;
if seed == 0.0 {
seed = rand::random::<f64>() * 1_000_000.0;
}
for file_path in files {
if file_path == "-" {
while let Some((x, n)) = read_line() {
lol::print_rainbow(&x, opts.freq, seed, opts.spread, opts.invert);
if n == 0 {
// EOF
break;
}
seed += 1.0;
}
} else {
let file = match File::open(&file_path) {
Ok(x) => x,
Err(e) => {
eprintln!("Could not open {}: {}.", file_path, e);
continue;
}
};
let buf = BufReader::new(file);
for x in buf.lines() {
match x {
Ok(x) => {
lol::print_rainbow(&x, opts.freq, seed, opts.spread, opts.invert);
println!();
seed += 1.0;
}
Err(e) => {
eprintln!("Error while reading {}: {}.", file_path, e);
continue;
}
}
}
}
seed += 1.0;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment