rename to yargs

update
main
blob42 8 months ago
parent 7494d1ca3f
commit 7d073c6eda

16
Cargo.lock generated

@ -99,14 +99,6 @@ version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961" checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961"
[[package]]
name = "colmap"
version = "0.1.0"
dependencies = [
"clap",
"regex",
]
[[package]] [[package]]
name = "colorchoice" name = "colorchoice"
version = "1.0.0" version = "1.0.0"
@ -266,3 +258,11 @@ name = "windows_x86_64_msvc"
version = "0.48.5" version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
[[package]]
name = "yargs"
version = "0.1.0"
dependencies = [
"clap",
"regex",
]

@ -1,5 +1,5 @@
[package] [package]
name = "colmap" name = "yargs"
version = "0.1.0" version = "0.1.0"
edition = "2021" edition = "2021"

@ -1,15 +1,29 @@
Very much work in progress. This is the first project in my Rust learning journey. Very much work in progress. This is the first project in my Rust learning journey.
Expect a lot of changes and refactoring. Expect a lot of changes and refactoring.
# Colmap # yargs
Colmap is hybrid between `awk` in `xargs`. It borrows from the former its ability `yargs` aims to be the `xargs` equivalent to tabular input. It borrows from `awk`
to work on tabular columns of text and allows for arbitrary commands to be the its ability to work on columns of text and allows for arbitrary
applied per column in a similar way to `xargs`. 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 The columns are called `fields`. The command to execute on each field is called
an `x-arg`. 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 ## Example
@ -23,33 +37,19 @@ input:
example usage: | x:arg example usage: | x:arg
-------------- | -------------- |
---------------- ----------------
colmap 'basename {}' "awk { print $1 }" yargs 'basename {}' "awk { print $1 }"
#OR #OR
colmap -f1 'basename {}' -f2 'awk { print $1 }' yargs -f1 'basename {}' -f2 'awk { print $1 }'
would output: `ebook.pdf | Title` would output: `ebook.pdf | Title`
- use colon as delimiter - 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 }'
```
--- ---

@ -1,7 +1,7 @@
## I am Using GitHub Under Protest ## I am Using GitHub Under Protest
This project is currently hosted on my [personal 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 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 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 like GitHub. If you want to contribute I encourage you to do so through the

@ -7,16 +7,18 @@
*/ */
use clap::Parser; use clap::Parser;
use colmap::parsing::DEFAULT_SEP_PATTERN; use yargs::parsing::DEFAULT_SEP_PATTERN;
#[derive(Parser)] #[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 /// The yargs command maps commands to text columns, it works like `xargs` for tabular text. Input
/// specified by the user. Commands are mapped to specific columns using positional arguments. /// 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. /// 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(author="blob42")]
#[command(version="0.1")] #[command(version="0.1")]
struct Cli { struct Cli {

Loading…
Cancel
Save