CLI program that takes tabular data as input and maps a random command to each input column.
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
blob42 14cd0990b6 yarg cmd execution prototype
- handle multiple yarg command son columns
2 months ago
examples lint / clippy 7 months ago
src yarg cmd execution prototype 2 months ago
tests yarg cmd execution prototype 2 months ago
.gitignore initial commit 1 year ago
Cargo.lock add assert_cmd, wip cli tests, capture stdin 7 months ago
Cargo.toml add assert_cmd, wip cli tests, capture stdin 7 months ago
README.md add cli tests + refactor 7 months ago
TODO.md yarg cmd execution prototype 2 months ago
github-protest.md rename to yargs 8 months ago

README.md

WIP pet project.

yargs

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 y-arg.

Usage

  1. passing column yargs as fields
foo_cmd | yargs --field-1='basename {}'  --field-2="awk { print $1 }"
foo_cmd | yargs -f1 'basename {}' -f2 'awk { print $1 }'
  1. Passing yargs as positional arguments
foo_cmd | yargs 'basename {}' 'awk { print $2 }'
  1. skipping fields
foo_cmd | yargs 'basename {}' - 'awk { print $2 }'
# keeps the second field unchanged

Example

input:

         field #1                 field #2
|--------------------------|   |--------------|
/long/path/to/some/ebook.pdf   | Title Of Ebook
                                 ____
                                   |
example usage:                     | y-arg
--------------                     |                     
                      ----------------                       
yargs 'basename {}' "awk { print $1 }"
                                                

#OR
yargs -f1 'basename {}' -f2 'awk { print $1 }'

would output: ebook.pdf | Title

  • use colon as delimiter

yargs -d':' -f1 '...'


I am using Github under protest