Filters Package for Golang
The Filters package is designed to allow the chaining of cli commands using stdin and stdout.
The command allows setting the commands explicitly or loading from a yaml file.
A Filter is any cli command, but primarily focused on the idea of unix cli commands being used as byte filters used to mangle and transform text and piping commands together.
A Chain is a sequential list of Filters with each piping its output into the next.
From either a chain or filter an Exec can be generated.
Input for an Exec is provided as a io.Reader and output is assigned as an io.Writer.
On an Exec from a chain, input is assigned to the first process and output assigned to the last. Everything in between is automatically piped to the next Filter.
Chains allow the application to load multiple chains in one yaml file and retrive them by title.
Filter YAML Example
Name: 'cat'
Domain: 'bash'
Version: '1.0'
Command: 'cat'
Arguments:
Chain YAML Example
Chain:
- Name: 'cat'
Domain: 'bash'
Version: '1.0'
Command: 'cat'
Arguments:
- Name: 'grep'
Domain: 'bash'
Version: '1.0'
Command: 'grep'
Arguments:
- 'wrong'
- Name: 'xargs'
Domain: 'bash'
Version: '1.0'
Command: 'xargs'
Arguments:
- '-n'
- '3'
Chains YAML Example
FirstChain:
Chain:
- Name: 'ls'
Domain: 'bash'
Version: '1.0'
Command: 'ls'
Arguments:
VCS:
Type: 'git'
Location: 'github.com'
- Name: 'grep'
Domain: 'bash'
Version: '1.0'
Command: 'grep'
Arguments:
- 'filters'
VCS:
Type: 'git'
Location: 'github.com'
- Name: 'xargs'
Domain: 'bash'
Version: '1.0'
Command: 'xargs'
Arguments:
- '-n'
- '4'
VCS:
Type: 'git'
Location: 'github.com'
SecondChain:
Chain:
- Name: 'ls'
Domain: 'bash'
Version: '1.0'
Command: 'ls'
Arguments:
VCS:
Type: 'git'
Location: 'github.com'
- Name: 'grep'
Domain: 'bash'
Version: '1.0'
Command: 'grep'
Arguments:
- 'filters'
VCS:
Type: 'git'
Location: 'github.com'
- Name: 'xargs'
Domain: 'bash'
Version: '1.0'
Command: 'xargs'
Arguments:
- '-n'
- '4'
VCS:
Type: 'git'
Location: 'github.com'
See the godocs for more information and examples.