ffr

for future reference
git clone https://git.davidvoz.net/ffr.git
Log | Files | Refs | README

commit aee22f03aa45ebd23883cf5f66b0b62a84059379
Author: David Voznyarskiy <31452046-davidvoz@users.noreply.gitlab.com>
Date:   Wed, 10 Dec 2025 22:00:03 -0800

initial commit

Diffstat:
ACargo.lock | 7+++++++
ACargo.toml | 4++++
AREADME.md | 20++++++++++++++++++++
Asrc/main.rs | 40++++++++++++++++++++++++++++++++++++++++
4 files changed, 71 insertions(+), 0 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "ffr" +version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml @@ -0,0 +1,4 @@ +[package] +name = "ffr" +version = "0.1.0" +edition = "2024" diff --git a/README.md b/README.md @@ -0,0 +1,20 @@ +A program to help quickly recall commands and notes. + +Below is an example of the ~/.local/share/ffr file + +``` +exiftool + : read metadata +#>tar +tar -czvf archive.tar.gz thing/ file + : compress +#>luks #>encrypt #>cryptsetup +sudo cryptsetup... + : additional notes +``` + +After compiling, the executible ran without argument prints out every line from the beginning until it reaches a #> or the end of the file. + +Running with an argument, tar for example, prints out all the notes below #>tar until it reaches another #> or the end of the file. + +Running with the argument luks, encrypt, or cryptsetup, all produces the same result. diff --git a/src/main.rs b/src/main.rs @@ -0,0 +1,40 @@ +use std::{env, fs}; + +fn main() { + let user_arg = env::args().nth(1); + let path = "/home/user/.local/share/ffr"; + let file_input = fs::read_to_string(path).unwrap_or_else(|e| panic!("ERROR: {e}")); + + match user_arg { + Some(arg) => print_arg(&file_input, &arg), + None => no_arg(&file_input), + } +} + +fn print_arg(input: &str, arg: &str) { + let keyword = format!("#>{arg}"); + let mut printing = false; + + for line in input.lines() { + if line.contains(&keyword) { + printing = true; + continue; + } + + if printing { + if line.starts_with("#>") { + break; + } + println!("{line}"); + } + } +} + +fn no_arg(input: &str) { + for line in input.lines() { + if line.starts_with("#>") { + break; + } + println!("{line}"); + } +}