-
Notifications
You must be signed in to change notification settings - Fork 2
feat: Add JSON pretty-printing with --indent parameter #38
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
base: main
Are you sure you want to change the base?
Conversation
pinbraerts
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Надо чуть-чуть полшлифовать пр. По логике не особо смотрел, если работает, то норм.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Удали из пр и добавь .vscode в .gitignore
| { | ||
| let mut lexer = lexer::Lexer::default(); | ||
| let mut parser = parser::Parser::default(); | ||
| let mut formatter = indent.map(|size| formatter::IndentFormatter::new(size)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
По идее можно
indent.map(formatter::IndentFormatter::new)| print_help(); | ||
| std::process::exit(0); | ||
| } | ||
| "--indent" => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let value = args.get(i + 1).ok_or_else(|| Error("--indent requires a value" ))?;
let indent = value.parse::<usize>()?;
return Ok(Args { indent: Some(indent) });| return Err("--indent requires a value".to_string()); | ||
| } | ||
| } | ||
| arg if arg.starts_with("--indent=") => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Зачем этот случай поддерживать, если можно его не поддерживать? Давай забьём на =
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тут явно что-то лишнее
Description
Implements JSON pretty-printing functionality as requested in the issue Indent and format #37. Adds
--indentparameter to control output formatting while maintaining rekson's core JSON fixing capabilities.Changes
--indentparameter with three modes:--indent: Preserve original spacing (no formatting changes)--indent 0: Compact output (collapse all spaces)--indent N: Pretty-print with N spaces indentationIndentFormatterstruct inrekson-lib/src/formatter.rsfor handling indentation logicsrc/cli.rsto parse--indentparameter with proper error handlingprocess_bytes_with_indent()functionImplementation Details
--indent 4and--indent=4syntaxTesting
Examples
Fixes the pretty-printing requirement from the original issue while maintaining backward compatibility.