Skip to content

Add --no-format flag to nickel convert#2529

Merged
L0r3m1p5um merged 1 commit intonickel-lang:masterfrom
costajohnt:feat/no-format-convert
Mar 3, 2026
Merged

Add --no-format flag to nickel convert#2529
L0r3m1p5um merged 1 commit intonickel-lang:masterfrom
costajohnt:feat/no-format-convert

Conversation

@costajohnt
Copy link
Contributor

Closes #2504

Adds a --no-format flag to nickel convert that skips the auto-formatting step. This is useful for batch conversions or cases where formatted output isn't needed.

Changes

  • Added --no-format boolean flag to ConvertCommand (clap #[arg(long)])
  • When set, the converted AST output is returned as-is without running through the formatter
  • Added snapshot tests for --no-format covering all input formats (JSON, YAML, TOML, text, Nickel, unknown extension)

Test plan

  • cargo test -p nickel-cli passes (all existing + new snapshot tests)
  • Manual verification: nickel convert --no-format produces unformatted output
  • Verified snapshot diffs show the expected difference (e.g. [1, 2] formatted vs [ 1, 2 ] unformatted)

@costajohnt costajohnt marked this pull request as ready for review February 28, 2026 01:48
Add a --no-formatting flag to the convert command that skips the
auto-formatting step on the converted output. This is useful for
batch conversions or cases where formatted output isn't needed.

- Add no_formatting bool field to ConvertCommand with clap #[arg(long)]
- Skip the format::format() call when the flag is set
- Add snapshot tests for --no-formatting covering all input formats
- Document the flag in the user manual

Closes nickel-lang#2504
@yannham
Copy link
Collaborator

yannham commented Mar 2, 2026

Hello, and thanks for your contribution! I think you didn't properly added the inputs for the snapshot tests, or maybe I'm missing something?

@L0r3m1p5um
Copy link
Collaborator

I think it's using the same inputs as the convert tests, but running them once with and once without the new flag.

Copy link
Collaborator

@yannham yannham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, indeed. Thanks for the contribution, LGTM!

@github-actions
Copy link
Contributor

github-actions bot commented Mar 2, 2026

🐰 Bencher Report

Branchfeat/no-format-convert
Testbedubuntu-latest
Click to view all benchmark results
BenchmarkLatencymicroseconds (µs)
diagnostics-benches/inputs/goto-perf.ncl📈 view plot
🚷 view threshold
12,216.00 µs
diagnostics-benches/inputs/large-record-tree.ncl📈 view plot
🚷 view threshold
221,680.00 µs
diagnostics-benches/inputs/redis-replication-controller.ncl📈 view plot
🚷 view threshold
356.09 µs
diagnostics-benches/inputs/small-record-tree.ncl📈 view plot
🚷 view threshold
563.31 µs
fibonacci 10📈 view plot
🚷 view threshold
235.98 µs
foldl arrays 50📈 view plot
🚷 view threshold
403.96 µs
foldl arrays 500📈 view plot
🚷 view threshold
2,992.60 µs
foldr strings 50📈 view plot
🚷 view threshold
3,053.30 µs
foldr strings 500📈 view plot
🚷 view threshold
29,792.00 µs
generate normal 250📈 view plot
🚷 view threshold
16,418.00 µs
generate normal 50📈 view plot
🚷 view threshold
1,087.00 µs
generate normal unchecked 1000📈 view plot
🚷 view threshold
1,870.90 µs
generate normal unchecked 200📈 view plot
🚷 view threshold
380.17 µs
init-diagnostics-benches/inputs/goto-perf.ncl📈 view plot
🚷 view threshold
60,451.00 µs
init-diagnostics-benches/inputs/large-record-tree.ncl📈 view plot
🚷 view threshold
229,910.00 µs
init-diagnostics-benches/inputs/redis-replication-controller.ncl📈 view plot
🚷 view threshold
55,442.00 µs
init-diagnostics-benches/inputs/small-record-tree.ncl📈 view plot
🚷 view threshold
56,326.00 µs
pidigits 100📈 view plot
🚷 view threshold
2,051.40 µs
pipe normal 20📈 view plot
🚷 view threshold
630.42 µs
pipe normal 200📈 view plot
🚷 view threshold
4,922.50 µs
product 30📈 view plot
🚷 view threshold
268.42 µs
requests-benches/inputs/goto-perf.ncl-000📈 view plot
🚷 view threshold
3,134.60 µs
requests-benches/inputs/large-record-tree.ncl-000📈 view plot
🚷 view threshold
678,230.00 µs
requests-benches/inputs/large-record-tree.ncl-001📈 view plot
🚷 view threshold
101.61 µs
scalar 10📈 view plot
🚷 view threshold
541.90 µs
sum 30📈 view plot
🚷 view threshold
279.99 µs
🐰 View full continuous benchmarking report in Bencher

@L0r3m1p5um L0r3m1p5um added this pull request to the merge queue Mar 3, 2026
Merged via the queue into nickel-lang:master with commit 4a5c027 Mar 3, 2026
4 checks 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.

Add an option to eschew formatting in nickel convert

3 participants