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

allow showing NUON diffs #91

Merged
merged 4 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.nuon diff=nuon
31 changes: 31 additions & 0 deletions scripts/print-nuon.nu
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env nu

def main [file: path]: [ nothing -> string ] {
if not ($file | path exists) {
error make {
msg: $"(ansi red_bold)file_not_found(ansi reset)",
label: {
text: "no such file",
span: (metadata $file).span,
},
help: $"`($file)` does not exist",
}
}

let content = open --raw $file

let data = try {
$content | from nuon
} catch {
error make {
msg: $"(ansi red_bold)invalid_nuon(ansi reset)",
label: {
text: "could not parse NUON",
span: (metadata $file).span,
},
help: $"`($file)` does not appear to be valid NUON",
}
}

$data | to nuon -i 4
}
5 changes: 5 additions & 0 deletions toolkit.nu
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ export def print-nupm-env [] {
print $'PATH: ($env.PATH?)'
print $'NU_LIB_DIRS: ($env.NU_LIB_DIRS?)'
}

# turn on pretty diffs for NUON data files
export def set-nuon-diff [] {
git config diff.nuon.textconv (pwd | path join scripts print-nuon.nu)
}
Loading