summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorivarlovlie <git@ivarlovlie.no>2022-12-20 21:51:39 +0100
committerivarlovlie <git@ivarlovlie.no>2022-12-20 21:51:39 +0100
commit87ee550abea331430fc2db0f1d96d6acbfa6c8f2 (patch)
tree96a6e126db498a2e5b562d9802651c62b630fe4b
downloadlearning-rust-87ee550abea331430fc2db0f1d96d6acbfa6c8f2.tar.xz
learning-rust-87ee550abea331430fc2db0f1d96d6acbfa6c8f2.zip
$(date "+%D %T")
-rw-r--r--.gitignore7
-rw-r--r--rust-cli/grrs/Cargo.toml9
-rw-r--r--rust-cli/grrs/src/main.rs21
-rwxr-xr-xsave.sh4
4 files changed, 41 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..ab1c2ef
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,7 @@
+debug/
+target/
+Cargo.lock
+**/*.rs.bk
+*.pdb
+.vscode
+.idea
diff --git a/rust-cli/grrs/Cargo.toml b/rust-cli/grrs/Cargo.toml
new file mode 100644
index 0000000..08077b2
--- /dev/null
+++ b/rust-cli/grrs/Cargo.toml
@@ -0,0 +1,9 @@
+[package]
+name = "grrs"
+version = "0.1.0"
+edition = "2018"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
+clap = { version = "4.0", features = ["derive"] } \ No newline at end of file
diff --git a/rust-cli/grrs/src/main.rs b/rust-cli/grrs/src/main.rs
new file mode 100644
index 0000000..09e2d3a
--- /dev/null
+++ b/rust-cli/grrs/src/main.rs
@@ -0,0 +1,21 @@
+use std::io::{BufReader, BufRead};
+use std::fs::File;
+use::clap::Parser;
+
+#[derive(Parser)]
+struct Cli {
+ pattern: String,
+ path: std::path::PathBuf,
+}
+
+
+fn main() {
+ let args = Cli::parse();
+ //println!("pattern: {}, path: {}",args.pattern, args.path.display());
+ let file = File::open(args.path).expect("could not read file");
+ let mut reader = BufReader::new(file);
+ for line in reader.lines() {
+ if line.unwrap_or_default().contains(&args.pattern) {
+ }
+ }
+}
diff --git a/save.sh b/save.sh
new file mode 100755
index 0000000..f472910
--- /dev/null
+++ b/save.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+git add .
+git commit -m '$(date "+%D %T")'
+git push