Skip to content

Add support for JSON output#47

Merged
AzisK merged 4 commits intomainfrom
Add-support-for-JSON-output
Feb 6, 2026
Merged

Add support for JSON output#47
AzisK merged 4 commits intomainfrom
Add-support-for-JSON-output

Conversation

@AzisK
Copy link
Owner

@AzisK AzisK commented Feb 6, 2026

No description provided.

@github-actions
Copy link

github-actions bot commented Feb 6, 2026

⸜(。˃ ᵕ ˂ )⸝♡ Thank you for opening this Pull Request, AzisK!

( ˶°ㅁ°) !! It's Trivia Time!

Here are 3 trivia questions to keep you entertained while CI runs.
(Feel free to demonstrate your knowledge and reply!)

🧩 Q1: In Night In The Woods, what is Mae Borowski mother's name?

A) Jenny
B) Margaret
C) Kate
D) Candy

🧩 Q2: What is the largest organ of the human body?

A) Heart
B) large Intestine
C) Liver
D) Skin

🧩 Q3: According to the lore of "Starbound", what does the "Colony Deed" do when it is placed down?

A) Teleports somebody from somewhere on the planet it is placed.
B) Teleports a random person to the location.
C) Materializes a new being at it's location.
D) Sends out an advertisement for someone to move in.

You got this! Remember, every bug is just a feature in disguise.

@github-actions
Copy link

github-actions bot commented Feb 6, 2026

Code Review

Great job overall! You’ve introduced JSON output support in a clean and organized way, improved user experience with an output file feature, and ensured backward compatibility with existing functionality. I have taken a deep dive into the code diff and here is my feedback.


Strengths

  1. Separation of Concerns:

    • The use of a new module is fantastic for enhancing maintainability and separation of concerns. This design makes the data structure reusable and keeps output formatting logic out of . Excellent modular programming!
  2. Code Quality:

    • The dataclass and its supporting constructs (, , ) are well-defined. Using type hints, default values, and a clean method simplify their usage and improve readability and usability. Fantastic work (lines: , 1-129)!!
  3. Backward Compatibility:

    • You’ve preserved the old text output format and ensured JSON and output file handling do not interfere with the user’s existing workflow. This is thoughtful and shows good attention to user experience (lines: , 125-210).
  4. Extensibility:

    • The design of the new JSON output feature is extensible. Adding new fields, categories, or formats would be straightforward due to the clear structure of in .
  5. Avoids Code Duplication:

    • Your succinct use of a single function (and conversion utilities like ) reduces redundancy in the code. By centralizing the conversion to JSON logic into one location, you’ve created a clean and DRY implementation! (lines: , 71-128). Love this!
  6. Error Handling:

    • Proper exception handling for and is in place and ensures a graceful exit without cluttering logs (lines: , 158-162). Great user-focused implementation.
  7. Logging Improvements:

    • The flag elegantly consolidates various conditions into a single, manageable concept that declutters the code and makes it easier to navigate and comprehend (lines: , 122). Excellent job simplifying the logic with this addition!

Suggestions for Improvements

  1. Validation for Output File

    • When writing to an output file, there is no error handling for file write issues (e.g., disk out of space, insufficient permissions). Adding a block around file writing operations (zpace/main.py) would improve robustness:
  2. Improve Variable Naming:

    • While most of the names are good, might be better renamed to . It would provide a more accurate description of its functionality (lines: , 121-122).
  3. Testing Edge Cases:

    • The calculation in (, line 105) will trigger a if is zero. Although this case might rarely occur, it’s worth ensuring it won’t crash:
  4. Improve JSON Indentation Customization:

    • Though your default is good, allowing the user to configure indentation at runtime (via a CLI flag) could offer added flexibility for those requiring minified JSON or different indentation styles.
  5. Add Type Hints for :

    • The arguments and lack type annotations in . Adding precise type hints would clarify their structure:
  6. Text File Output - Magic Number for Column Width:

    • In text file output mode, the fixed column width () used for the separators feels like a magic number. It would be better to either make it configurable or dynamically determine the width based on content or terminal size.
  7. Expand Documentation:

    • The CLI update to support JSON output is well reflected in the , but it lacks details about the exact JSON schema and examples of how users might use the JSON output programmatically. Adding more examples and use cases would drive adoption further (lines: , 348-422).
  8. Progress Bar Logic:

    • The conditional to disable the progress bar (lines: , 107) duplicated in multiple places ( and ). Consider abstracting this logic into a helper function to avoid repeated patterns:

Security Considerations

Your changes adhere well to general security practices. However, there are a couple of minor points to keep in mind:

  1. Sanitizing Paths in Output:

    • Ensure paths written to JSON files are escaped to prevent injection or malicious path traversal attacks. Python’s already handles escaping, but double-check for edge cases.
  2. File Writing Permissions:

    • Warn users when writing files to non-owned directories via the flag. Without sufficient permissions or disk space, the process could fail silently.

Testing Recommendations

  1. Add automated tests for:

    • JSON formatting logic: Test the and methods for edge cases, like empty results or special directories.
    • Output file handling: Simulate writing both text and JSON files while testing edge cases (e.g., I/O failures).
    • Corner cases like disk size being improperly reported or being .
  2. Verify cross-platform compatibility:

    • Run integration tests across Linux, macOS, and Windows to confirm consistent behavior for disk size, trash paths, and symlink handling.

Motivation and Applause 🎉

This is an exciting PR that adds real value to the tool, making it far more versatile and appealing for developers and system administrators! Your clean and thoughtful implementation reflects a strong understanding of the problem and the end-user’s needs. The modular design of , the user-focused handling of CLI flags, and the efforts to maintain backward compatibility demonstrate excellent engineering practices.

Keep up the great work—your contributions are making Zpace even better! 🚀

@github-actions
Copy link

github-actions bot commented Feb 6, 2026

🎉 All tests passed! Here's a dog for you! 🐶

Dog

@AzisK AzisK merged commit d02cec5 into main Feb 6, 2026
29 checks passed
@AzisK AzisK deleted the Add-support-for-JSON-output branch February 17, 2026 15:11
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.

1 participant

Comments