Skip to content

Add lift and unlift commands for NSV line-level escaping#8

Merged
namingbe merged 4 commits intomasterfrom
claude/implement-lift-unlift-uPe1M
Mar 15, 2026
Merged

Add lift and unlift commands for NSV line-level escaping#8
namingbe merged 4 commits intomasterfrom
claude/implement-lift-unlift-uPe1M

Conversation

@namingbe
Copy link
Copy Markdown
Contributor

Summary

This PR adds two new commands to the NSV CLI tool: lift and unlift. These commands apply NSV escaping/unescaping at the line level, allowing users to collapse or restore one structural dimension of NSV data.

Key Changes

  • New lift command (alias l): Applies NSV escaping to each line, converting empty lines to backslash lines and escaping existing backslashes
  • New unlift command (alias u): Applies NSV unescaping to each line, reversing the lift operation
  • Both commands support reading from a file argument or stdin (when omitted or "-")
  • Comprehensive test suite (tests/test_lift_unlift.sh) with 20+ test cases covering:
    • Empty input and single lines
    • Backslash escaping and unescaping
    • NSV structure preservation
    • Multiple empty lines
    • Trailing newline handling
    • Roundtrip verification (lift→unlift returns original)
    • Stdin input support
    • Command aliases
    • Existing NSV fixture files

Implementation Details

  • Both functions follow the same pattern: read input, split on LF, apply the appropriate transformation to each line, and write with LF terminators
  • Properly handles trailing newlines by treating them as terminators rather than creating empty lines
  • Uses existing nsv::escape_bytes() and nsv::unescape_bytes() functions from the NSV module
  • All output lines are guaranteed to have trailing newlines for consistency

https://claude.ai/code/session_01ETp6Za1KCCnFFsrvYQML4s

claude added 4 commits March 15, 2026 12:33
Implement the line-level lift/unlift operations from the ENSV spec.
lift applies NSV escape to each line; unlift applies unescape.
These are inverses: unlift(lift(x)) == x for all inputs.

Includes aliases (l/u) and a 25-case test suite covering roundtrips,
edge cases, and existing NSV fixtures.

https://claude.ai/code/session_01ETp6Za1KCCnFFsrvYQML4s
Transpose's 't' alias is justified by convention across table-handling
frameworks and its longer name. Lift/unlift are short enough as-is,
and single-letter aliases would conflict with future un- subcommands.

https://claude.ai/code/session_01ETp6Za1KCCnFFsrvYQML4s
@namingbe namingbe merged commit 6200f94 into master Mar 15, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants