update README to add windows instructions

This commit is contained in:
mtgmonkey
2025-07-29 13:50:34 -04:00
parent 7cda8ecac1
commit 08cdaada97
5 changed files with 37 additions and 17 deletions

3
.gitignore vendored
View File

@@ -1,3 +0,0 @@
games.csv
out.csv
result

View File

@@ -11,15 +11,29 @@ This program serves to take a list of boardgames as a csv and return a csv with
### Run the sample ### Run the sample
`cat sample_in.csv | nix run` `cp sample_in.csv in.csv`
`nix run`
the output `out.csv` should match the provided `sample_out.csv` the output `out.csv` should match the provided `sample_out.csv`
## Quick Windows user guide
- Make a new folder
- Put `rust_elaborator.exe` into that folder
- Copy your `in.csv`, a list of game names as specified in `Usage`, or `out.csv`, an output from when this program ran previously, into the new folder
- Double-click `rust_elaborator.exe` to run it
- Check that `out.csv` is satisfactory
## Usage ## Usage
The program reads a csv from stdin and outputs it to `out.csv`. The following command reads the contents of `in.csv` into the program and runs it. # WARNING: files may be overwritten
`cat in.csv | rust_elaborator` The files `in.csv`, `out.csv`, `test.csv`, `copy.csv`, and possibly others may be overwritten and data loss may occur. Run this program in an empty directory with a copy of `in.csv` or `out.csv` and nothing else present for safety.
The program reads a file `in.csv` or `out.csv` and outpus it to `out.csv`. The following command reads the contents of `in.csv` into the program and runs it.
note that on windows, `rust_elaborator` instead looks like `rust_elaborator.exe`
`rust_elaborator`
`in.csv` must be formatted as follows... `in.csv` must be formatted as follows...
@@ -46,8 +60,4 @@ where `title` can be anything.
Capitalization does not matter. Capitalization does not matter.
Additional columns will not be present in `out.csv`. Additional columns will not be present in `out.csv`.
If you have an existing `out.csv`, you can add new rows and avoid recalling the rows that are already filled in with the flag `--mode expand`. If `out.csv` is present, the program will take it as input and elaborate on it. This will fill in rows that have a) a blank second column or b) NOT_FOUND in the second column, if possible.
`cat out.csv | nix run . -- --mode expand`
This will only check rows that have a) a blank second column or b) NOT_FOUND in the second column.

Binary file not shown.

View File

@@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};
#[derive(Parser, Debug)] #[derive(Parser, Debug)]
#[command(version, about, long_about = None)] #[command(version, about, long_about = None)]
pub struct Args { pub struct Args {
#[arg(short, long, default_value_t = ("elaborate".to_string()))] #[arg(short, long, default_value_t = ("infer".to_string()))]
pub mode: String, pub mode: String,
} }

View File

@@ -2,7 +2,7 @@ use clap::Parser;
use reqwest::header::USER_AGENT; use reqwest::header::USER_AGENT;
use rust_elaborator::*; use rust_elaborator::*;
use std::io; use std::io;
use std::io::prelude::*; use std::mem::drop;
#[tokio::main] #[tokio::main]
async fn main() -> Result<(), reqwest::Error> { async fn main() -> Result<(), reqwest::Error> {
@@ -11,6 +11,13 @@ async fn main() -> Result<(), reqwest::Error> {
match args.mode.as_str() { match args.mode.as_str() {
"elaborate" => make_out_from_in().await, "elaborate" => make_out_from_in().await,
"expand" => make_out_from_out().await, "expand" => make_out_from_out().await,
"infer" => {
if std::fs::exists("out.csv").unwrap() {
make_out_from_out().await
} else {
make_out_from_in().await
}
}
_ => panic!(), _ => panic!(),
}; };
Ok(()) Ok(())
@@ -137,11 +144,13 @@ fn find_best_boardgame(
} }
async fn make_out_from_in() -> Result<(), Box<dyn std::error::Error>> { async fn make_out_from_in() -> Result<(), Box<dyn std::error::Error>> {
println!("making out.csv from in.csv");
use std::fs::File; use std::fs::File;
use std::io::prelude::*; use std::io::prelude::*;
let mut out = File::create("out.csv").unwrap(); let mut out = File::create_new("out.csv").unwrap();
let mut inn = File::open("in.csv").unwrap();
let mut writer = csv::Writer::from_writer(out); let mut writer = csv::Writer::from_writer(out);
let mut reader = csv::Reader::from_reader(io::stdin()); let mut reader = csv::Reader::from_reader(inn);
writer writer
.write_record(&[ .write_record(&[
"title", "title",
@@ -217,10 +226,13 @@ async fn make_out_from_in() -> Result<(), Box<dyn std::error::Error>> {
} }
async fn make_out_from_out() -> Result<(), Box<dyn std::error::Error>> { async fn make_out_from_out() -> Result<(), Box<dyn std::error::Error>> {
println!("making out.csv from out.csv");
use std::fs::File; use std::fs::File;
std::fs::copy("out.csv", "copy.csv").unwrap();
let mut copy = File::open("copy.csv").unwrap();
let mut reader = csv::Reader::from_reader(copy);
let mut out = File::create("out.csv").unwrap(); let mut out = File::create("out.csv").unwrap();
let mut writer = csv::Writer::from_writer(out); let mut writer = csv::Writer::from_writer(out);
let mut reader = csv::Reader::from_reader(io::stdin());
writer writer
.write_record(&[ .write_record(&[
"title", "title",
@@ -286,7 +298,7 @@ async fn make_out_from_out() -> Result<(), Box<dyn std::error::Error>> {
maxplaytime.as_str(), maxplaytime.as_str(),
age.as_str(), age.as_str(),
]) ])
.unwrap() .unwrap();
} }
None => writer None => writer
.write_record(&[title, "NOT_FOUND", "", "", "", "", "", ""]) .write_record(&[title, "NOT_FOUND", "", "", "", "", "", ""])
@@ -299,5 +311,6 @@ async fn make_out_from_out() -> Result<(), Box<dyn std::error::Error>> {
]); ]);
}; };
} }
std::fs::remove_file("copy.csv");
Ok(()) Ok(())
} }