[go: up one dir, main page]

Skip to content
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

Draft: Add a --json flag to output json. #1099

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

jorikvanveen
Copy link
@jorikvanveen jorikvanveen commented Oct 13, 2024

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:
image

and you can then use other nushell operations to do something with this data:
image

TODO

  • Use cargo fmt
  • Add necessary tests
  • Update default config/theme in README (if applicable)
  • Update man page at lsd/doc/lsd.md (if applicable)

Copy link
muniu-bot bot commented Oct 13, 2024

[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.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@muniu-bot muniu-bot bot added the size/L label Oct 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant