Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ Because it is a FAQ, the major differences between this project and uutils are:
- [x] fold
- [x] grep
- [x] head
- [x] join
- [x] link
- [x] ls
- [x] mkdir
Expand Down Expand Up @@ -204,7 +205,6 @@ Because it is a FAQ, the major differences between this project and uutils are:
### Misc. category
- [ ] awk
- [ ] fuser
- [ ] join
- [ ] lp
- [ ] m4
- [ ] mailx
Expand Down
4 changes: 0 additions & 4 deletions file/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,3 @@ path = "./file.rs"
[[bin]]
name = "find"
path = "./find.rs"

[[bin]]
name = "join"
path = "./join.rs"
1 change: 0 additions & 1 deletion file/tests/file-tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ mod dd;
mod file;
mod find;
mod od;
mod join;
2 changes: 1 addition & 1 deletion misc/tests/misc-tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
//

mod r#false;
mod r#true;
mod test;
mod r#true;
5 changes: 5 additions & 0 deletions text/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ atty.workspace = true
diff = "0.1"
dirs = "5.0"
deunicode = "1.6"
walkdir = "2"

[[bin]]
name = "asa"
Expand All @@ -45,6 +46,10 @@ path = "./diff.rs"
name = "cut"
path = "./cut.rs"

[[bin]]
name = "join"
path = "./join.rs"

[[bin]]
name = "uniq"
path = "./uniq.rs"
Expand Down
16 changes: 6 additions & 10 deletions file/join.rs → text/join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ struct Args {
}

fn parse_fields(line: &str, sep: char) -> Vec<String> {
line.split(sep)
.map(|s| s.to_string())
.collect()
line.split(sep).map(|s| s.to_string()).collect()
}

fn process_files2(
Expand All @@ -73,7 +71,7 @@ fn process_files2(
a: u8,
e: Option<String>,
o: Option<Vec<String>>,
v: u8
v: u8,
) -> Result<(), Box<dyn std::error::Error>> {
// code to support stdin
let stdin = io::stdin();
Expand Down Expand Up @@ -111,20 +109,18 @@ fn process_files2(
let f_num: Vec<&str> = num.split('.').collect();
if f_num[0] == "1" {
if fields1.len() <= f_num[1].parse::<usize>()? - 1 {
if let Some(e) = &e {
if let Some(e) = &e {
res.push(e.to_string());
}
}
else {
} else {
res.push(fields1[f_num[1].parse::<usize>()? - 1].clone());
}
} else if f_num[0] == "2" {
if fields2.len() <= f_num[1].parse::<usize>()? - 1 {
if let Some(e) = &e {
res.push(e.to_string());
}
}
else {
} else {
res.push(fields2[f_num[1].parse::<usize>()? - 1].clone());
}
}
Expand Down Expand Up @@ -180,7 +176,7 @@ fn join(args: Args) -> Result<(), Box<dyn std::error::Error>> {
args.additional,
args.empty,
args.order,
args.unpairable
args.unpairable,
)?;

Ok(())
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 10 additions & 2 deletions file/tests/join/mod.rs → text/tests/join/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,14 @@ fn e_test() {
let project_root = env!("CARGO_MANIFEST_DIR");
let file1 = format!("{}/tests/join/file5.txt", project_root);
let file2 = format!("{}/tests/join/file6.txt", project_root);
let args = ["-o", "1.2,2.1,2.2", "-e", "Wandalen", file1.as_str(), file2.as_str()];
let args = [
"-o",
"1.2,2.1,2.2",
"-e",
"Wandalen",
file1.as_str(),
file2.as_str(),
];

let expected_output = "Alice 1 HR\nBob 2 Finance\nCharlie 3 IT\nKos 4 Wandalen\n";

Expand Down Expand Up @@ -118,7 +125,8 @@ fn three_fields_test() {
let file2 = format!("{}/tests/join/file4.txt", project_root);
let args = [file1.as_str(), file2.as_str()];

let expected_output = "1 Bob HR Director HR\n2 Charlie Finance Analyst Finance\n3 Alice Engineering Manager IT\n";
let expected_output =
"1 Bob HR Director HR\n2 Charlie Finance Analyst Finance\n3 Alice Engineering Manager IT\n";

run_test_join(&args, &expected_output, "", 0)
}
Expand Down
1 change: 1 addition & 0 deletions text/tests/text-tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ mod expand;
mod fold;
mod grep;
mod head;
mod join;
mod nl;
mod paste;
mod pr;
Expand Down