tristanls / snippet-cli

Snippet command-line interface
1 stars 0 forks source link

Add ability to specify filters by an alias #3

Closed tristanls closed 10 years ago

tristanls commented 10 years ago

Setup a filters/format or something similar as a directory. In there, put files that are the --filter snippets. This way, someone can specify on the command line:

~$ snippet parse my.log --do combined-apache-log

Where their filter resides in:

snippet-cli
|- do
   |- combined-apache-log

And snippet-cli/do/combined-apache-log contents are partial Logstash filter specifications (they will be surrounded by filter { ... }:

grok {
  match => { "message" => "%{COMBINEDAPACHELOG}" }
}
date {
  match => [ "timestamp" , "dd/MMM/yyyy:HH:mm:ss Z" ]
}

Alternatively, instead of an option, perhaps require a positional argument instead (and rename the directory to snippet-cli/format:

~$ snippet parse combined-apache-log my.log

Could even do tab autocompletion based on the file names present in format directory.

tristanls commented 10 years ago

Implemented in tristanls/snippet-cli@24700f369736e88554d1bfad4a2895f9cf17f92b .