diff --git a/Cargo.lock b/Cargo.lock index a7edda7..fa1f1f8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -99,14 +99,6 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961" -[[package]] -name = "colmap" -version = "0.1.0" -dependencies = [ - "clap", - "regex", -] - [[package]] name = "colorchoice" version = "1.0.0" @@ -266,3 +258,11 @@ name = "windows_x86_64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "yargs" +version = "0.1.0" +dependencies = [ + "clap", + "regex", +] diff --git a/Cargo.toml b/Cargo.toml index 36f5784..2e2db2c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "colmap" +name = "yargs" version = "0.1.0" edition = "2021" diff --git a/README.md b/README.md index 49c9507..6190c86 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,29 @@ Very much work in progress. This is the first project in my Rust learning journey. Expect a lot of changes and refactoring. -# Colmap +# yargs -Colmap is hybrid between `awk` in `xargs`. It borrows from the former its ability -to work on tabular columns of text and allows for arbitrary commands to be -applied per column in a similar way to `xargs`. +`yargs` aims to be the `xargs` equivalent to tabular input. It borrows from `awk` +the its ability to work on columns of text and allows for arbitrary +commands to be applied per column in a similar way to `xargs`. The columns are called `fields`. The command to execute on each field is called an `x-arg`. +# Usage + +1. passing column yargs as fields + +```shell +foo_cmd | yargs --field-1='basename {}' --field-2="awk { print $1 }" +foo_cmd | yargs -f1 'basename {}' -f2 'awk { print $1 }' +``` + +2. Passing `yargs` as positional arguments + +```shell +foo_cmd | yargs 'basename {}' 'awk { print $2 }' +``` ## Example @@ -23,33 +37,19 @@ input: example usage: | x:arg -------------- | ---------------- - colmap 'basename {}' "awk { print $1 }" + yargs 'basename {}' "awk { print $1 }" #OR - colmap -f1 'basename {}' -f2 'awk { print $1 }' + yargs -f1 'basename {}' -f2 'awk { print $1 }' would output: `ebook.pdf | Title` - use colon as delimiter -`colmap -d':' -f1 '...'` +`yargs -d':' -f1 '...'` -### Ways of passing x-args - -1. passing column x-args as fields - -```shell -foo_cmd | colmap --field-1='basename {}' --field-2="awk { print $1 }" -foo_cmd | colmap -f1 'basename {}' -f2 'awk { print $1 }' -``` - -2. Passing `xargs` as positional arguments - -```shell -foo_cmd | colmap 'basename {}' 'awk { print $2 }' -``` --- diff --git a/github-protest.md b/github-protest.md index 0f1fd97..3e0f5c7 100644 --- a/github-protest.md +++ b/github-protest.md @@ -1,7 +1,7 @@ ## I am Using GitHub Under Protest This project is currently hosted on my [personal -forge](https://git.blob42.xyz/sp4ke/colmap) and mirrored on GitHub. This is not +forge](https://git.blob42.xyz/sp4ke/yargs) and mirrored on GitHub. This is not ideal; GitHub is a proprietary, trade-secret system that is not Free and Open Souce Software (FOSS). I am deeply concerned about using a proprietary system like GitHub. If you want to contribute I encourage you to do so through the diff --git a/src/main.rs b/src/main.rs index 2d288db..345a475 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,16 +7,18 @@ */ use clap::Parser; -use colmap::parsing::DEFAULT_SEP_PATTERN; +use yargs::parsing::DEFAULT_SEP_PATTERN; #[derive(Parser)] -/// colmap - map commands to columns of text input +/// yargs - map commands to columns of text input /// -/// The colmap command reads text from stdin as columns. Each column is then passed to a command -/// specified by the user. Commands are mapped to specific columns using positional arguments. +/// The yargs command maps commands to text columns, it works like `xargs` for tabular text. Input +/// is parsed into columns then passed to commands specified by the user. Commands are mapped to +/// specific columns using positional +/// arguments. /// /// The first command is applied to the first column, the second command to the second column, etc. -#[command(name="colmap")] +#[command(name="yargs")] #[command(author="blob42")] #[command(version="0.1")] struct Cli {