Draft: Add a --json flag to output json.
This PR adds a --json flag which causes lsd to output the Metas as JSON.
It's a basic proof of concept I put together in an evening, so there are some .unwrap()s and rough edges. It's meant to show what I imagine this feature to look like so you can decide whether this is something you actually want implemented in lsd. If it is I can start working on a more serious implementation.
Why?
Combining this flag with something like nushell allows users to create ls aliases that output structured nu data but still look pretty.
For example, this alias:
def --wrapped ls [...rest] {
lsd ...$rest --json --icon always --icon-theme fancy --color always
| from json
| get 0.content
| select type display size date
| update date {|row| $row.date | into datetime}
| update size {|row| $row.size | into filesize}
}
results in this output:
and you can then use other nushell operations to do something with this data:
TODO
- [x] Use
cargo fmt - [ ] Add necessary tests
- [ ] Update default config/theme in README (if applicable)
- [ ] Update man page at lsd/doc/lsd.md (if applicable)
[APPROVALNOTIFIER] This PR is NOT APPROVED
This pull-request has been approved by: jorikvanveen
Once this PR has been reviewed and has the lgtm label, please assign zwpaper for approval by writing /assign @zwpaper in a comment. For more information see:The Kubernetes Code Review Process.
The full list of commands accepted by this bot can be found here.
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment
Will this be merged? Another nushell user here