allow for default parser
hey there, could you support setting a default parser in the config file?
thanks,
Are you talking about a default parser for a specific content type (e.g. I want my own JSON parser instead of the built-in one) or just a default in general (e.g. I'm only ever dealing with JSON so always use the JSON parser)?
If it's the former, you should be able to define which parser to use for which content-type in the configs: content_types: xml: XMLParser plist: PlistParser json: JSON ...
If it's the latter, because Kronk figures out the parser to use from the returned content-type, it wouldn't make much sense to always use, say JSON. That said, you can definitely set a default parser per host/uri in the configs: uri_options: example.com: :parser: XMLParser
hey jeremie, thanks
what I'm looking for is if there is no content type, ie
cat json_file | kronk
using -P json works. Maybe allowing for something like that in the config would work. :parser: json
For files, it should know how to parse files if they have the correct extension:
kronk json_file.json
Stdin parsing is tougher. What I've done in the past is just alias the command, which still lets you pass more arguments and options as needed:
alias kjson="kronk -P json"
Yeah. Sorry. I'm pipping in from some other command not actually a file
On Thursday, August 22, 2013, Jeremie wrote:
If you name your file *.json it should know how to parse it.
— Reply to this email directly or view it on GitHubhttps://github.com/yaks/kronk/issues/24#issuecomment-23114326 .
Some sort of content-type detection might be a solution. Gotta think this one through.