@cthru/bastr
v0.3.3
Published
CLI string manipulation utility
Readme
bastr
CLI string manipulation utility
Description
bastr takes stdin content and provide functions to modify the content. It is
meant as an alternative to using sed, tr, awk and other utilities for
simple string and array manipulation.
The unix utilities are probably more performant and more powerful - this utility only exists because it is easier and more semantic to use.
Advanced Use: Scripts
Scripts in bastr are sequences of predefined actions. To create a new script,
use the bs script:add command and follow along with the prompts
To list your scripts, use bs script:list.
To apply a script, use (someprocess) | bs script [scriptname]
Examples
$ echo -n "capitalize all words" | bs split " " | bs capitalize | bs join " "
>>> Capitalize All Words$ ps | bs lineArray | bs findItem bash | bs getItem 0 | bs split -r "\s+" | bs getItem 3
>>> /usr/local/bin/bashUsage
$ npm install -g @cthru/bastr
$ (someProcess) | bs COMMAND
running command...
$ bs (-v|--version|version)
@cthru/bastr/0.3.3 darwin-x64 node-v10.10.0
$ bs --help [COMMAND]
USAGE
$ (someProcess) | bs COMMAND
...Commands
(someProcess) | bs capitalize(someProcess) | bs findItem TERM(someProcess) | bs getItem [INDEX](someProcess) | bs help [COMMAND](someProcess) | bs join [GLUE](someProcess) | bs replace SEARCHTERM REPLACETERM(someProcess) | bs script [SCRIPTNAME]bs script:addbs script:delete SCRIPTNAMEbs script:list(someProcess) | bs select INDEXES(someProcess) | bs split DELIMITER(someProcess) | bs toArray(someProcess) | bs trim TRIMCHAR
(someProcess) | bs capitalize
Capitalizes string or [string]
USAGE
$ (someProcess) | bs capitalize
OPTIONS
-a, --all Target all letters, not just first
-d, --decapitalize De-Capitalize instead
ALIASES
$ (someProcess) | bs capSee code: src/commands/capitalize.js
(someProcess) | bs findItem TERM
Get an Item from an array, or a character from a string
USAGE
$ (someProcess) | bs findItem TERM
ARGUMENTS
TERM The term to search for
ALIASES
$ (someProcess) | bs search
$ (someProcess) | bs filter
$ (someProcess) | bs findSee code: src/commands/findItem.js
(someProcess) | bs getItem [INDEX]
Get an Item from an array, or a character from a string
USAGE
$ (someProcess) | bs getItem [INDEX]
ARGUMENTS
INDEX Zero-based index for the array item to select
ALIASES
$ (someProcess) | bs getSee code: src/commands/getItem.js
(someProcess) | bs help [COMMAND]
display help for bs
USAGE
$ (someProcess) | bs help [COMMAND]
ARGUMENTS
COMMAND command to show help for
OPTIONS
--all see all commands in CLISee code: @oclif/plugin-help
(someProcess) | bs join [GLUE]
Join multiple array elements together
USAGE
$ (someProcess) | bs join [GLUE]
ARGUMENTS
GLUE [default: ] Glue to use for joinSee code: src/commands/join.js
(someProcess) | bs replace SEARCHTERM REPLACETERM
Replaces Values in strings or arrays
USAGE
$ (someProcess) | bs replace SEARCHTERM REPLACETERM
ARGUMENTS
SEARCHTERM The term to search for
REPLACETERM The term to replace searchTerm with
OPTIONS
-c, --case-sensitive match only case sensitive occurances
-f, --first only replace the first occurance
-r, --regex use regular expression in search termSee code: src/commands/replace.js
(someProcess) | bs script [SCRIPTNAME]
Apply a script to bash output
USAGE
$ (someProcess) | bs script [SCRIPTNAME]
ARGUMENTS
SCRIPTNAME The script you want to apply
OPTIONS
-s, --show-cli-equivalent Show what this script would look like on bashSee code: src/commands/script/index.js
bs script:add
Add a new Script
USAGE
$ bs script:addSee code: src/commands/script/add.js
bs script:delete SCRIPTNAME
Delete a named script
USAGE
$ bs script:delete SCRIPTNAME
ARGUMENTS
SCRIPTNAME delete the `scriptName` scriptSee code: src/commands/script/delete.js
bs script:list
List your Scripts
USAGE
$ bs script:listSee code: src/commands/script/list.js
(someProcess) | bs select INDEXES
Selects array items by index list
USAGE
$ (someProcess) | bs select INDEXES
ARGUMENTS
INDEXES A list of indexes delimited by comma. Eg. '1,2,3' and '-3,5,6-'See code: src/commands/select.js
(someProcess) | bs split DELIMITER
Split a string into an array based on a delimiter
USAGE
$ (someProcess) | bs split DELIMITER
ARGUMENTS
DELIMITER [default: ] Delimiter to use as split point
OPTIONS
-r, --regex Delimiter is regexSee code: src/commands/split.js
(someProcess) | bs toArray
Split multiline string into array of lines
USAGE
$ (someProcess) | bs toArray
ALIASES
$ (someProcess) | bs lineSplit
$ (someProcess) | bs line2array
$ (someProcess) | bs lineArraySee code: src/commands/toArray.js
(someProcess) | bs trim TRIMCHAR
Trim a string or an array of strings
USAGE
$ (someProcess) | bs trim TRIMCHAR
ARGUMENTS
TRIMCHAR [default: ] The character to trim
OPTIONS
-s, --sides=left|right|both [default: both] Configure which side(s) to trimSee code: src/commands/trim.js
