Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rosylilly/lf
lf is a lightweight command-line LTSV processor
https://github.com/rosylilly/lf
Last synced: 5 days ago
JSON representation
lf is a lightweight command-line LTSV processor
- Host: GitHub
- URL: https://github.com/rosylilly/lf
- Owner: rosylilly
- License: mit
- Created: 2014-09-25T16:49:32.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-09-26T00:00:38.000Z (over 10 years ago)
- Last Synced: 2024-12-22T13:14:54.528Z (15 days ago)
- Language: Ruby
- Homepage:
- Size: 137 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# lf
__lf__ is a lightweight command-line LTSV processor.
## Installation
Install it yourself as:
$ gem install lf
## Usage
```
$ lf -h
Usage: lf [options] [file]
-r, --require FILE Require a file
-c, --[no-]color Colored output
-f, --format FORMAT Choose a format(ltsv, table)
-b, --[no-]buffered Flush the output after each LTSV row
-h, --help Show this message
-v, --version Show version
```### Input
Specify LTSV file path:
```
$ lf example.ltsv
```Or input via pipe:
```
$ tail -f example.ltsv | lf
```### Filters
You can set filters to lf: `filter-name:args`
```
$ lf label:tag1,foo example.ltsv
tag1:test foo:bar
$ lf label:tag1 example.ltsv
tag1:test
```#### Label filter
`label:select labels(comma separated)`
```
$ lf label:tag1,foo example.ltsv
tag1:test foo:bar
tag1:test foo:baz
$ lf label:tag1 example.ltsv
tag1:test
tag1:test
```#### Ignore filter
`ignore:ignore labels(comma separated)`
```
$ lf ignore:tag1 example.ltsv
foo:bar test:key long:long long long message long long long label:short
foo:baz test:key long:long long long message long long long label:short
```#### Equal filter
`equal:label:value`
```
$ lf eq:foo:bar example.ltsv
tag1:test foo:bar test:key long:long long long message long long long label:short
```#### Regexp filter
`regexp:label:regexp`
```
$ lf reg:foo:r$ example.ltsv
tag1:test foo:bar test:key long:long long long message long long long label:short
```#### Customu filter
Make your custom filters:
```ruby
# custom-filter.rb
class StatusCode < Lf::Filter
filter_alias :statusdef initialize(status_code)
@status_code = status_code.to_i
enddef apply(row)
row[:status].to_i == @status_code ? row : nil
end
end
``````
$ lf --require custom-filter.rb status:200 nginx.log
```## Contributing
1. Fork it ( https://github.com/rosylilly/lf/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request