-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Formatters #16
base: master
Are you sure you want to change the base?
Formatters #16
Conversation
Also: - output doesn't have to be console logged. - formatter output method always passed an array.
IMO this should be a concern for custom / other tools / shell scripts |
Care to elaborate? The idea is that its simply a way to 'save' If this sort of formatting is part of a separate CLI, then whats the point of |
I mean it would be possible to create a module that just prints json objects such that you would do:
But that doesn't let you reuse select or reduce functions at all. So then you have a tool that just wraps the entirety of |
i dont dislike the idea, i just dont want to bloat jog itself, i also want a repl and a query language but that's not going to be built within jog itself. ill take a closer look a the implementation and consider it |
i dont know, personally I would still just write a little shell script or alias called say |
I guess we have to agree to disagree :) I'll put some more thought into how I can do what I want cleanly without having to fork jog. |
sounds good. i would even prefer |
I could see that. jsontools or something. |
I 'scratched my own itch' and created https://github.com/cpsubrian/node-joli which satisfies my needs. So, unless you think some version of this will be included in |
Introduces the concept of 'formatters' and ALL CLI output runs through a formatter.
A formatter is merely a commonjs module that exports an object. The object should follow the following signature:
Formatters can live in three possible locations:
lib/formatters
$HOME/.jog/formatters
$CWD/.jog/formatters
This allows someone to maintain formatters that they like to use on either a per-machine, or per-project basis. Awesome! Also, the formatters are loaded in that order, so project formatters can override machine ones, or core ones.
Four core formatters are included:
You use the formatters via the
--output
command-line option.-j --json
is aliased to--output json
-c --color
is aliased to--output color
I think this is a really flexible approach. For example you could create a formatter that saves images, or a formatter that renders a CLI bar chart, or whatever.