Skip to content

Cli/list/ o/ show fflags#2569

Merged
ChanTsune merged 2 commits into
mainfrom
cli/list/-O/--show-fflags
Jan 5, 2026
Merged

Cli/list/ o/ show fflags#2569
ChanTsune merged 2 commits into
mainfrom
cli/list/-O/--show-fflags

Conversation

@ChanTsune
Copy link
Copy Markdown
Owner

@ChanTsune ChanTsune commented Jan 4, 2026

Summary by CodeRabbit

  • New Features

    • Added --show-fflags (-O) to the list command to optionally display file flags in table, CSV/TSV and JSONL outputs; header and columns appear only when enabled (off by default).
  • Tests

    • Added end-to-end tests covering table/header, CSV, JSONL and plain list behaviors with and without the new option.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 4, 2026

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

📝 Walkthrough

Walkthrough

Adds a new show_fflags list option (short -O) and threads it through ListOptions, TableRow, and list-formatting paths so file flags can be conditionally rendered in table, JSONL, CSV, and TSV outputs; includes end-to-end tests covering the new option.

Changes

Cohort / File(s) Summary
List command & options
cli/src/command/list.rs
Added show_fflags to ListCommand/ListOptions; added fflags: Vec<String> to TableRow; introduced detailed_format_name; updated formatting logic to include optional Fflags column and per-row values; changed json_line_entries_to to accept &ListOptions.
Stdio options wiring
cli/src/command/stdio.rs
Initialized and propagated new ListOptions.show_fflags field where list options are constructed.
Tests — integration
cli/tests/cli/list.rs, cli/tests/cli/list/option_show_fflags.rs
Registered new test module and added six end-to-end tests validating Fflags visibility/omission across table (with header), JSONL, and CSV outputs and combinations of flags/options.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • Cli/list/format csv tsv #2489: Modifies list output pipeline and delimited/CSV/TSV formatting that this PR extends to include fflags and show_fflags.

Poem

🐰 I hopped through code to find a clue,
A tiny flag that now shows true,
Rows and CSV, JSONL delight,
-O lifts shadows into light,
I nibble bugs and dance—hooray! 🚩

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title is vague and uses non-descriptive formatting with unclear abbreviations and spacing, making it difficult to understand the main change. Clarify the title to something like 'Add --show-fflags option to list command' or 'Support displaying file flags in list output' for better readability and clarity.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3596fc7 and f32bc2f.

📒 Files selected for processing (4)
  • cli/src/command/list.rs
  • cli/src/command/stdio.rs
  • cli/tests/cli/list.rs
  • cli/tests/cli/list/option_show_fflags.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • cli/src/command/stdio.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: tier1 (macos-latest, stable)
  • GitHub Check: tier1 (macos-latest, nightly)
  • GitHub Check: tier1 (ubuntu-22.04-arm, beta)
  • GitHub Check: Test on NetBSD
  • GitHub Check: rust_check_format
  • GitHub Check: Test WebAssembly (beta, wasm32-wasip2)
  • GitHub Check: tier1 (windows-11-arm, stable)
🔇 Additional comments (8)
cli/src/command/list.rs (6)

73-78: LGTM! Clean option declaration.

The new -O/--show-fflags option is well-documented and follows the existing pattern for optional display flags in the list command.


730-793: LGTM! Consistent conditional column handling.

The header and row building logic correctly uses Option types with then_some/then to conditionally include the Fflags column. The fflags are appropriately formatted as comma-separated values or "-" when empty, consistent with other columns.


829-852: LGTM! Column indexing updated correctly.

The size column indices are adjusted to account for the optional Fflags column, and the colorization array correctly includes the new column color. The index calculation (line 830) is somewhat fragile and depends on column ordering, but this fragility exists in the pre-existing code and is not introduced by this change.


865-881: LGTM! Good refactoring to reduce duplication.

The detailed_format_name helper function consolidates name formatting logic that honors both classify and hide_control_chars options. This improves maintainability by centralizing the formatting rules.


1044-1045: LGTM! JSONL output correctly implements conditional fflags.

The FileInfo struct uses #[serde(skip_serializing_if = "Option::is_none")] to conditionally include the fflags field in JSONL output. The function signature update to accept options enables checking the show_fflags flag, and fflags are appropriately represented as an array in JSON format.

Also applies to: 1062-1107


1160-1213: LGTM! CSV/TSV output correctly implements conditional fflags.

The header and row logic properly use the Option + flatten pattern to conditionally include the fflags column. Fflags are appropriately represented as comma-separated values, and the CSV library will handle quoting if needed (though file flags typically don't contain commas).

cli/tests/cli/list.rs (1)

20-21: LGTM! Test module properly declared.

The new option_show_fflags test module follows the existing pattern and is appropriately guarded for non-wasm targets.

cli/tests/cli/list/option_show_fflags.rs (1)

1-173: LGTM! Comprehensive test coverage for fflags display.

The test suite thoroughly covers all major output formats (table, CSV, JSONL) with both positive and negative cases:

  • Tests verify fflags are displayed when -O is provided
  • Tests verify fflags are omitted when -O is not provided
  • Header test confirms the "Fflags" column appears correctly
  • JSONL tests validate conditional field inclusion using serde
  • CSV test validates proper formatting including quoted multi-flag values

The tests are well-structured, clearly documented, and use appropriate assertions.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added the cli This issue is about cli application label Jan 4, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @ChanTsune, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the pna command-line tool by introducing comprehensive support for handling file flags. It allows users to preserve file flags during archive creation, appending, and updating, and to restore them during extraction. Additionally, it provides new options for the list command to display these file flags in various output formats, offering greater transparency and control over archived file attributes. This feature is implemented with robust, platform-specific logic for macOS, Linux, Android, and FreeBSD, ensuring compatibility and reliability.

Highlights

  • File Flag Preservation: Introduced support for archiving and extracting file flags (e.g., 'uchg', 'nodump', 'hidden') on Unix-like systems (macOS, Linux, Android, FreeBSD). This allows for more comprehensive preservation of file attributes.
  • CLI Options for File Flags: Added new command-line options, --keep-fflags and --no-keep-fflags, for the create, append, extract, and update commands. These options provide granular control over whether file flags are preserved during archive operations.
  • Display File Flags in List Command: Implemented a new --show-fflags (-O) option for the list command. When enabled, this option displays file flags in table, CSV, and JSONL output formats, enhancing visibility into archived file attributes.
  • Platform-Specific Implementations: Developed robust, platform-specific logic for retrieving and setting file flags on macOS, Linux/Android, and FreeBSD. This includes handling system calls, mapping flags to human-readable names, and managing error conditions like unsupported filesystems or symlinks.
  • Integration with Core Logic: Integrated file flag handling into the core KeepOptions and apply_metadata mechanisms, ensuring consistent behavior across all relevant CLI commands and simplifying future maintenance.
  • Comprehensive Testing: Added a suite of new integration tests to verify the correct functionality and display of file flags across various list command output formats (table, CSV, JSONL), both with and without the --show-fflags option.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for file flags (fflags) in the CLI. The primary change is the addition of a -O/--show-fflags option to the list command, allowing users to view file flags in various output formats. The implementation is thorough, including a new ffLg chunk type, platform-specific logic for macOS, Linux, and FreeBSD to get/set these flags, and comprehensive tests for the new listing functionality. The underlying infrastructure for creating and extracting archives with file flags is also added. The code is well-structured, but I have a couple of suggestions to improve consistency and safety in the macOS-specific implementation.

Comment thread cli/src/utils/os/unix/fs.rs
Comment thread cli/src/utils/os/unix/fs.rs
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (4)
cli/src/ext.rs (1)

47-60: Clean implementation with a note on error handling.

The implementation is idiomatic and efficient. One consideration: invalid UTF-8 data in ffLg chunks is silently ignored (line 54). This is likely acceptable for robustness, but you may want to log a warning for corrupted flag data to aid debugging.

Optional: Log invalid UTF-8 flag data
     #[inline]
     fn fflags(&self) -> Vec<String> {
         self.extra_chunks()
             .iter()
             .filter_map(|c| {
                 if c.ty() == chunk::ffLg {
-                    std::str::from_utf8(c.data()).ok().map(str::to_string)
+                    match std::str::from_utf8(c.data()) {
+                        Ok(s) => Some(s.to_string()),
+                        Err(e) => {
+                            log::warn!("Invalid UTF-8 in ffLg chunk: {e}");
+                            None
+                        }
+                    }
                 } else {
                     None
                 }
             })
             .collect()
     }
cli/src/command/append.rs (1)

394-394: Consider adding CLI flags for file flags preservation in append mode.

The fflags_strategy is hardcoded to FflagsStrategy::Never, while other strategies like permission_strategy, xattr_strategy, and acl_strategy use from_flags() to respect user-provided CLI options. This inconsistency means users cannot control file flags preservation during append operations, even though the stdio.rs implementation (which also handles append) supports --keep-fflags and --no-keep-fflags flags.

Proposed enhancement to add fflags CLI support

Add the CLI flags to AppendCommand:

+    #[arg(
+        long,
+        visible_aliases = ["preserve-fflags", "fflags"],
+        requires = "unstable",
+        help = "Archiving the file flags of the files (unstable)"
+    )]
+    keep_fflags: bool,
+    #[arg(
+        long,
+        visible_aliases = ["no-preserve-fflags", "no-fflags"],
+        requires = "unstable",
+        help = "Do not archive file flags of files. This is the inverse option of --keep-fflags (unstable)"
+    )]
+    no_keep_fflags: bool,

Add the ArgGroup to the command attributes:

+    group(ArgGroup::new("keep-fflags-flag").args(["keep_fflags", "no_keep_fflags"])),

Update the initialization:

-        fflags_strategy: FflagsStrategy::Never,
+        fflags_strategy: FflagsStrategy::from_flags(args.keep_fflags, args.no_keep_fflags),
cli/src/command/update.rs (1)

403-403: Consider adding CLI flags for file flags preservation in update mode.

Similar to the append command, the fflags_strategy is hardcoded to FflagsStrategy::Never instead of using from_flags() to respect user preferences. The stdio.rs implementation supports --keep-fflags in update mode (line 1047), but the standalone UpdateCommand does not expose these flags, creating an inconsistency between the two interfaces.

Proposed enhancement to add fflags CLI support

Add the CLI flags to UpdateCommand (similar to other preserve options):

+    #[arg(
+        long,
+        visible_aliases = ["preserve-fflags", "fflags"],
+        requires = "unstable",
+        help = "Archiving the file flags of the files (unstable)"
+    )]
+    keep_fflags: bool,
+    #[arg(
+        long,
+        visible_aliases = ["no-preserve-fflags", "no-fflags"],
+        requires = "unstable",
+        help = "Do not archive file flags of files. This is the inverse option of --keep-fflags (unstable)"
+    )]
+    no_keep_fflags: bool,

Add the ArgGroup:

+    group(ArgGroup::new("keep-fflags-flag").args(["keep_fflags", "no_keep_fflags"])),

Update the initialization:

-        fflags_strategy: FflagsStrategy::Never,
+        fflags_strategy: FflagsStrategy::from_flags(args.keep_fflags, args.no_keep_fflags),
cli/src/command/extract.rs (1)

422-422: Consider adding CLI flags for file flags preservation in extract mode.

The fflags_strategy is hardcoded to FflagsStrategy::Never, preventing users from restoring file flags during extraction. The stdio.rs implementation (line 750) supports --keep-fflags flags for extract operations, but the standalone ExtractCommand does not expose these options.

Proposed enhancement to add fflags CLI support

Add the CLI flags to ExtractCommand:

+    #[arg(
+        long,
+        visible_alias = "preserve-fflags",
+        requires = "unstable",
+        help = "Restore the file flags of the files (unstable)"
+    )]
+    keep_fflags: bool,
+    #[arg(
+        long,
+        visible_alias = "no-preserve-fflags",
+        requires = "unstable",
+        help = "Do not restore file flags. This is the inverse option of --keep-fflags (unstable)"
+    )]
+    no_keep_fflags: bool,

Add the ArgGroup:

+    group(ArgGroup::new("keep-fflags-flag").args(["keep_fflags", "no_keep_fflags"])),

Update the initialization:

-        fflags_strategy: FflagsStrategy::Never,
+        fflags_strategy: FflagsStrategy::from_flags(args.keep_fflags, args.no_keep_fflags),
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 113252d and e819cb0.

📒 Files selected for processing (16)
  • cli/src/chunk.rs
  • cli/src/chunk/fflag.rs
  • cli/src/command/append.rs
  • cli/src/command/core.rs
  • cli/src/command/create.rs
  • cli/src/command/extract.rs
  • cli/src/command/list.rs
  • cli/src/command/stdio.rs
  • cli/src/command/update.rs
  • cli/src/ext.rs
  • cli/src/utils/fs.rs
  • cli/src/utils/fs/nodump.rs
  • cli/src/utils/os/unix/fs.rs
  • cli/tests/cli/list.rs
  • cli/tests/cli/list/option_show_fflags.rs
  • resources/test/zstd_keep_fflags.pna
🧰 Additional context used
🧬 Code graph analysis (6)
cli/src/utils/os/unix/fs.rs (1)
cli/src/utils/fs.rs (2)
  • get_flags (69-89)
  • set_flags (91-111)
cli/src/utils/fs/nodump.rs (2)
cli/src/utils/fs.rs (1)
  • get_flags (69-89)
cli/src/utils/os/unix/fs.rs (3)
  • get_flags (24-58)
  • get_flags (108-160)
  • get_flags (235-272)
cli/src/utils/fs.rs (1)
cli/src/utils/os/unix/fs.rs (6)
  • get_flags (24-58)
  • get_flags (108-160)
  • get_flags (235-272)
  • set_flags (68-87)
  • set_flags (171-230)
  • set_flags (282-313)
cli/src/command/stdio.rs (1)
cli/src/command/core.rs (4)
  • from_flags (117-125)
  • from_flags (135-143)
  • from_flags (153-161)
  • from_flags (171-179)
cli/src/command/extract.rs (2)
cli/src/utils/fs.rs (1)
  • set_flags (91-111)
cli/src/utils/os/unix/fs.rs (3)
  • set_flags (68-87)
  • set_flags (171-230)
  • set_flags (282-313)
cli/src/command/core.rs (2)
cli/src/utils/fs.rs (1)
  • get_flags (69-89)
cli/src/utils/os/unix/fs.rs (3)
  • get_flags (24-58)
  • get_flags (108-160)
  • get_flags (235-272)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: Test on NetBSD
  • GitHub Check: tier1 (ubuntu-22.04-arm, nightly)
  • GitHub Check: tier1 (ubuntu-22.04-arm, stable)
  • GitHub Check: tier1 (windows-11-arm, nightly)
  • GitHub Check: tier1 (macos-latest, stable)
  • GitHub Check: tier1 (macos-latest, nightly)
  • GitHub Check: msrv (ubuntu-latest, portable-network-archive)
🔇 Additional comments (39)
cli/src/utils/fs/nodump.rs (1)

1-9: Clean refactoring to use centralized flag API.

The implementation correctly delegates to the new get_flags API and performs a simple string comparison. This is a good simplification over the previous platform-specific code paths.

cli/src/utils/os/unix/fs.rs (7)

23-58: Solid macOS flag retrieval implementation.

The lstat-based approach correctly extracts BSD file flags and maps them to human-readable names. The flag mapping aligns with standard BSD conventions.


94-105: Correct Linux file flag constants.

The flag definitions match the Linux kernel's linux/fs.h header values and cover the most commonly used ext2/ext3/ext4/btrfs attributes.


107-160: Robust Linux flag retrieval with proper edge case handling.

The implementation correctly handles symlinks (ELOOP), unsupported filesystems (ENOTTY/EOPNOTSUPP), and maps Linux flags to libarchive-compatible BSD names. The ioctl approach is the standard method for Linux file attributes.


162-230: Linux flag setter with correct merge semantics.

The read-modify-write approach matches libarchive behavior on Linux. Good optimizations include early return for empty flags and skipping the write when flags haven't changed. The error handling for symlinks and unsupported filesystems is appropriate.


234-272: FreeBSD flag retrieval with platform-specific flags.

Correctly includes FreeBSD-specific flags (UF_NOUNLINK, SF_NOUNLINK) not present on macOS. Uses nix's lstat wrapper for cleaner error handling.


282-313: FreeBSD flag setter - verify empty flags behavior.

The early return on line 285-287 prevents clearing all flags when an empty slice is passed. Note that the macOS implementation doesn't have this early return, meaning it would call lchflags(path, 0) for empty flags (clearing all flags).

If the intent is to never clear flags when given an empty slice, this is correct. If parity with macOS is desired, consider adding the same check to macOS set_flags.


60-92: Extern declaration for lchflags is correct.

The function signature matches macOS specifications, and all flag constants are available in the libc crate. The implementation correctly handles symlink-safe flag setting with proper error handling.

cli/src/chunk.rs (1)

2-5: LGTM!

The module declaration and re-export follow the existing pattern established by the acl module.

cli/tests/cli/list.rs (1)

20-21: LGTM!

The test module declaration follows the existing pattern and appropriately excludes wasm targets where file flags aren't applicable.

cli/src/chunk/fflag.rs (1)

1-14: Well-documented chunk type definition.

The chunk naming convention is clearly documented. The unsafe usage is acceptable here since *b"ffLg" is a compile-time constant with exactly 4 ASCII bytes, which is the requirement for ChunkType.

The #[allow(non_upper_case_globals)] attribute appropriately handles Rust's naming conventions while preserving the semantically meaningful case in the chunk identifier.

cli/src/command/create.rs (2)

9-9: LGTM!

Import addition for the new FflagsStrategy enum.


480-480: Sensible default for file flags strategy.

Setting FflagsStrategy::Never as the default is appropriate for backward compatibility. Users will need to explicitly opt-in to preserve file flags.

cli/src/utils/fs.rs (2)

69-89: LGTM! Platform-specific flag retrieval is well-structured.

The get_flags function properly delegates to platform-specific implementations on supported Unix variants (macOS, Linux, Android, FreeBSD) and returns an empty vector on unsupported platforms. This pattern is consistent with other platform-specific functions in this file like lchown.


91-111: LGTM! Platform-specific flag setting follows established patterns.

The set_flags function correctly implements a no-op for unsupported platforms and delegates to the Unix-specific implementation on supported systems. The error handling strategy (returning Ok(()) on unsupported platforms) aligns with the existing codebase patterns.

cli/src/command/extract.rs (1)

917-932: LGTM! File flags restoration follows established patterns.

The file flags restoration logic correctly mirrors the ACL and xattr restoration patterns:

  • Checks the strategy before applying flags
  • Handles empty flag lists appropriately
  • Provides user-friendly warnings for unsupported filesystems
  • Propagates actual errors for proper failure handling
cli/src/command/stdio.rs (6)

191-204: LGTM! CLI arguments for file flags are well-structured.

The keep_fflags and no_keep_fflags arguments are properly defined with:

  • Appropriate visibility aliases for user convenience
  • Unstable feature gate for experimental functionality
  • Clear help text describing the behavior

The ArgGroup at line 63 correctly prevents conflicting flags.


656-656: LGTM! File flags strategy properly wired in create mode.

The FflagsStrategy::from_flags call correctly translates CLI arguments into the strategy, allowing users to control file flags preservation during archive creation.


750-750: LGTM! File flags strategy properly wired in extract mode.

Consistent with create mode, the extract path correctly uses from_flags to respect user preferences for file flags restoration.


910-910: LGTM! File flags strategy properly wired in append mode.

The append path correctly uses from_flags, enabling user control over file flags preservation when appending to archives.


1047-1047: LGTM! File flags strategy properly wired in update mode.

Consistent with other modes, the update path properly uses from_flags to respect user preferences.


827-827: The feature is already implemented.

The list command has a fully functional --show-fflags / -O flag (defined in cli/src/command/list.rs lines 74-78) with comprehensive test coverage in cli/tests/cli/list/option_show_fflags.rs. Users can already control fflags display via -O in list mode.

The hardcoded show_fflags: false in cli/src/command/stdio.rs line 827 is part of a separate tar-compatible stdin/stdout interface (the run_list_archive function), where show_xattr and show_acl are also hardcoded. This appears to be an intentionally simplified mode with restricted display options.

cli/tests/cli/list/option_show_fflags.rs (6)

8-28: LGTM! Comprehensive test coverage for table format.

The test validates that file flags are correctly displayed in table format with the -O flag, including multiple flag combinations and proper formatting.


34-56: LGTM! Header validation is thorough.

The test confirms that the "Fflags" column header is properly included and aligned when using --header with -O.


62-85: LGTM! CSV format handling is correct.

The test validates CSV output including proper quoting for multi-flag entries (e.g., "hidden,schg"), which is essential for CSV parsing.


91-117: LGTM! JSONL format correctly represents fflags as arrays.

The test validates that file flags are properly serialized as JSON arrays, enabling structured parsing of the output.


123-148: LGTM! Important negative test case.

This test validates that fflags are not included in JSON output when the -O flag is not specified, ensuring clean output by default.


154-173: LGTM! Ensures backward compatibility.

This test confirms that the fflags column is not displayed by default, maintaining existing behavior when the -O flag is not used.

cli/src/command/core.rs (3)

164-180: LGTM! Consistent implementation following established patterns.

The FflagsStrategy enum and its from_flags constructor follow the same design as XattrStrategy, AclStrategy, and PermissionStrategy, ensuring consistency across the codebase.


188-188: LGTM! Proper integration into KeepOptions.

The fflags_strategy field is appropriately placed alongside other metadata preservation strategies.


791-807: LGTM! Correct implementation with appropriate error handling.

The file flags handling follows the same pattern as extended attributes (lines 770-786), including proper error handling for unsupported filesystems and platforms. The warning for unsupported cases is helpful for users.

cli/src/command/list.rs (8)

73-78: LGTM! Clear and well-documented CLI option.

The -O/--show-fflags flag follows existing conventions and provides helpful examples of flag types in the help text.


319-319: LGTM! Proper data model extension.

The fflags field is appropriately added to TableRow and populated using the NormalEntryExt::fflags() method, maintaining consistency with other metadata fields.

Also applies to: 393-393


419-419: LGTM! Proper options propagation.

The show_fflags flag is correctly threaded from ListCommand args to ListOptions, maintaining the established pattern.

Also applies to: 506-506


730-793: LGTM! Clean conditional column implementation.

The header and row building logic elegantly handles the optional Fflags column using Option::then() and flatten(), maintaining consistency between headers and data. The formatting correctly shows "-" for no flags and comma-separated values for multiple flags.


829-852: LGTM! Correct column indexing and styling.

The column alignment calculation properly adjusts for the optional Fflags column:

  • Without -O: aligns columns 3-4 (Raw Size, Compressed Size)
  • With -O: aligns columns 4-5 (Raw Size, Compressed Size after Fflags)

The colorization array uses Option and flatten() to conditionally include the Fflags color, maintaining the correct color-to-column mapping.


1044-1045: LGTM! Proper JSON serialization with conditional inclusion.

The fflags field in FileInfo uses #[serde(skip_serializing_if = "Option::is_none")] to cleanly omit the field when not requested, and the conditional logic correctly includes the flags array only when show_fflags is true.

Also applies to: 1062-1107


1160-1222: LGTM! CSV/TSV output correctly handles optional fflags column.

The delimited output logic consistently applies the conditional column pattern. The comma-joining for multi-flag entries (line 1208) is safe since flag names are simple identifiers, and the csv crate automatically handles quoting when needed.


865-881: LGTM! Useful helper for name formatting.

The detailed_format_name function consolidates entry name formatting logic, properly handling both the classify option (adding / and @ indicators) and hide_control_chars option. The implementation correctly handles all entry types.

Comment thread cli/src/command/list.rs Fixed
Comment thread cli/src/command/list.rs Fixed
Comment thread cli/src/command/list.rs Fixed
Comment thread cli/src/command/list.rs Fixed
Comment thread cli/src/command/list.rs Fixed
Comment thread cli/src/command/list.rs Fixed
@ChanTsune ChanTsune force-pushed the cli/list/-O/--show-fflags branch from e819cb0 to 3596fc7 Compare January 4, 2026 15:04
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
cli/src/command/list.rs (1)

1194-1213: Closure usage is appropriate here.

Line 1208 uses .then(|| row.fflags.join(",")) instead of .then_some(row.fflags.join(",")). This is correct because:

  • The closure avoids evaluating join(",") when show_fflags is false
  • Using then_some() would always execute the join operation

If static analysis flags this as an "unnecessary closure," it would be a false positive.

🧹 Nitpick comments (1)
cli/src/command/list.rs (1)

865-881: LGTM!

Good refactoring to extract the name formatting logic into a dedicated helper function. This improves code maintainability and reduces duplication.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e819cb0 and 3596fc7.

📒 Files selected for processing (5)
  • cli/src/command/list.rs
  • cli/src/command/stdio.rs
  • cli/tests/cli/list.rs
  • cli/tests/cli/list/option_show_fflags.rs
  • resources/test/zstd_keep_fflags.pna
🚧 Files skipped from review as they are similar to previous changes (3)
  • cli/tests/cli/list.rs
  • cli/src/command/stdio.rs
  • cli/tests/cli/list/option_show_fflags.rs
🔇 Additional comments (11)
cli/src/command/list.rs (11)

73-78: LGTM!

The CLI argument definition is clear and follows standard patterns. The short flag -O is a reasonable choice for displaying file flags.


319-319: LGTM!

The fflags field is appropriately typed as Vec<String> to hold multiple flag names.


393-393: LGTM!

The fflags are correctly populated from the entry's metadata.


419-419: LGTM!

The show_fflags option is correctly threaded through the command to the options struct.

Also applies to: 506-506


730-742: LGTM!

The conditional header construction using then_some() and flatten() is clean and correctly includes the Fflags column when enabled.


756-793: LGTM!

The row construction correctly includes the optional fflags column with appropriate formatting (comma-separated list or "-" for empty). The closure at line 766 is necessary for the conditional logic.


829-852: LGTM!

The alignment and colorization logic correctly accounts for the conditional Fflags column. The size column indices are properly calculated: when fflags are shown, Raw Size is column 4 and Compressed Size is column 5; otherwise they're columns 3 and 4.


1044-1045: LGTM!

The conditional serialization of fflags using skip_serializing_if ensures the field is only included in JSON output when requested.


1062-1066: LGTM!

The signature update to accept options parameter is necessary to support the conditional fflags output.


1103-1107: LGTM!

The fflags are correctly included in JSONL output only when show_fflags is enabled.


1160-1175: LGTM!

The CSV/TSV header correctly includes the fflags column when enabled, following the same pattern used for the table format.

@ChanTsune ChanTsune force-pushed the cli/list/-O/--show-fflags branch from 3596fc7 to f32bc2f Compare January 5, 2026 01:02
@ChanTsune ChanTsune merged commit 14a3343 into main Jan 5, 2026
105 of 106 checks passed
@ChanTsune ChanTsune deleted the cli/list/-O/--show-fflags branch January 5, 2026 04:42
@coderabbitai coderabbitai Bot mentioned this pull request Feb 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli This issue is about cli application

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants