Skip to content

Implement TarOperation and TarParam foundations#49

Open
stillbeingnick wants to merge 20 commits into
uutils:mainfrom
stillbeingnick:feat/taroperation-tarparam
Open

Implement TarOperation and TarParam foundations#49
stillbeingnick wants to merge 20 commits into
uutils:mainfrom
stillbeingnick:feat/taroperation-tarparam

Conversation

@stillbeingnick

Copy link
Copy Markdown

This PR builds on the great work done by @kaladron and lays out the foundation to enable adding operations and options moving forward. Leveraging rust enums and building behavioral control with the enum dispatch pattern.

There are 3 critical pieces to this foundational layer.

TarParams

  • TarParams provides highline access to arguments passed in and some convenience to the options set by the user that are called during execution. This also serves as the functional place that clap arguments are processed from uu_main. ArgMatches are pumped in and TarParams, TarOptions, and the TarOperation pop out.

TarOptions

  • An enum used to capture arguments and potential subarguments passed in via clap and command line. Due to the overwhelming amount of options that tar has, we needed a way to store these while also potentially caputuring data that could be associated with that option. Like BlockingFactor might take in a u32, while Verbose is only a flag so its presentance in a list is enough, and a rust enum is the best way to handle this wide swath of possibilities. A Vec of these options is stored in TarParams and created when TarParams::with_operation() is called.

TarOperation

  • This trait serves as the execution hook from processing from clap ArgMatchees to execution. Each Main Operation mode is created as a file (create.rs, extract.rs) and each of these have a new type associated with their respected operation. Which then impl the TarOperation trait and the exec method. This gives us a place to call our main operation modes and decouple each operation from one another, but also allowing the reuse of operations in other operations. For example, using append in the update operation.

While this is just the bones it will continue to morph and change as more functionality is built into tar.

@stillbeingnick

Copy link
Copy Markdown
Author

Just wanted to give this a bump, @kaladron or @sylvestre let me know if we need anything.

Comment thread src/uu/tar/src/operations/operation.rs
@stillbeingnick

Copy link
Copy Markdown
Author

Wanted to give this another bump @sylvestre @cakebaker. The PR after this I plan to rework the Clap arg processing so we can not only take care of @sylvestre suggestion to help make TarOperation more sane but also see if we can start addressing #55.

@kaladron

kaladron commented Dec 14, 2025 via email

Copy link
Copy Markdown
Collaborator

@stillbeingnick

Copy link
Copy Markdown
Author

Sorry, it's performance review season at work and a lot of things in life are delayed at the moment.

On Sun, Dec 14, 2025, 18:55 Nicholas Still @.> wrote: stillbeingnick left a comment (uutils/tar#49) <#49 (comment)> Wanted to give this another bump @sylvestre https://github.com/sylvestre @cakebaker https://github.com/cakebaker. The PR after this I plan to rework the Clap arg processing so we can not only take care of @sylvestre https://github.com/sylvestre suggestion to help make TarOperation more sane but also see if we can start addressing #55 <#55>. — Reply to this email directly, view it on GitHub <#49 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAC4FO5SVFIW4Q42Y4RDUID4BWXAJAVCNFSM6AAAAACM7IZVVWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTMNJRHAYTANZUHA . You are receiving this because you were mentioned.Message ID: @.>

All good @sylvestre reviewed unless you are a maintainer now too @kaladron. But always open to more reviews.

Comment thread src/uu/tar/src/tar.rs
Comment thread src/uu/tar/src/options/options.rs Outdated
Comment thread src/uu/tar/src/options/options.rs Outdated
Removing for match loop going over all matched args. Moved to standard if get_* for specific matches.
@stillbeingnick

stillbeingnick commented Dec 15, 2025

Copy link
Copy Markdown
Author

@cakebaker Thank you for the review! Items requested in the review are taken care of.

@stillbeingnick

Copy link
Copy Markdown
Author

Every time I somehow forget to run clippy and fmt! I need CI for my brain. Should be good to go now.

Comment thread src/uu/tar/Cargo.toml Outdated
Removing for match loop going over all matched args. Moved to standard if get_* for specific matches.
Removing for match loop going over all matched args. Moved to standard if get_* for specific matches.
Adding TarParam and TarOperation framework

clippy and cargo fmt
changing arg match taroption processing

Removing for match loop going over all matched args. Moved to standard if get_* for specific matches.

fmt and derive default tarparams
clippy and cargo fmt
changing arg match taroption processing

Removing for match loop going over all matched args. Moved to standard if get_* for specific matches.

fmt and derive default tarparams

cargo workspace dependency fixes
Adding TarParam and TarOperation framework

clippy and cargo fmt
changing arg match taroption processing

Removing for match loop going over all matched args. Moved to standard if get_* for specific matches.
Revert "changing arg match taroption processing"

This reverts commit 4bef208.

changing arg match taroption processing

Removing for match loop going over all matched args. Moved to standard if get_* for specific matches.
cargo workspace dependency fixes
Adding TarParam and TarOperation framework

clippy and cargo fmt
changing arg match taroption processing

Removing for match loop going over all matched args. Moved to standard if get_* for specific matches.

fmt and derive default tarparams
@stillbeingnick

Copy link
Copy Markdown
Author

Sorry @sylvestre and @cakebaker for the absolute mess of commit history something blew up and my local squashed just fine but the PR commits and the branch in my fork won't squash. So I am not sure if it is github or most likely a me issue.

type Error = TarError;
fn try_from(value: &str) -> Result<Self, Self::Error> {
match value {
"concate" => Ok(Self::Concatenate),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
"concate" => Ok(Self::Concatenate),
"concatenate" => Ok(Self::Concatenate),

no ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Suggested change
"concate" => Ok(Self::Concatenate),
"catenate" | "concatenate" => Ok(Self::Concatenate),

Ya actually both gnu tar takes both -> All Tar options, BSD tar doesn't have concatenate. Also correct the spelling in this one, thank you for the catch!

Comment thread src/uu/tar/src/options/options.rs Outdated
/// [`TarParams`] Holds common information that is parsed from
/// command line arguments. That changes the current execution of
/// tar.
#[allow(dead_code)]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can we avoid this ?
it is usually a sign that the code needs to be refactored

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Turns out the lint wasn't needed. But there was dead enum variants and methods for TarParams and Options, those were removed and commited.

Comment thread src/uu/tar/src/options/options.rs Outdated
} else {
// TODO: update messaging
Err(Box::new(TarError::TarOperationError(
"Error processing: Operations".to_string(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

yeah, we should probably provide more information in case of errors, no?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes I added the ids of the arguments passed in the error message so if the error is ever called it will provide some information. Clap will catch the malformed or non-existent args so this error message should never get executed but if it does we will have a thread to pull on.

In the future once we get more consistent language we can change the operation error messaging.

@sylvestre

Copy link
Copy Markdown
Contributor

linter is failing

@kaladron

kaladron commented Jun 7, 2026

Copy link
Copy Markdown
Collaborator

I keep thinking about this every month or so. The problem is that adding this up front, I have no way of knowing if this is a good approach or not, and then I worry about us having infrastructure that we feel we have to use instead of refactoring up to good infra that meets out needs. As such, I would actually prefer to close this and figure this out once we have a set of features that demand it.

Sorry for the delay in coming to this conclusion. =( I should have been faster about it.

@stillbeingnick

Copy link
Copy Markdown
Author

@kaladron I get not wanting to have the over-head but we need to have a plan. A sense of direction for this.

I took what was already laid out in GNU tar and attempted to create a modular solution so we could impl one piece at a time. I wanted to put something in just to get the discussion started. I created charts and documentation so we could hate on it and make it better. I don't want uutar to be mine I want it to be ours.

If my design sucks lets come up with a better one. If we want tweaks lets tweak it. I don't want to build uutar in silos never discussing anything.

This project needs input, discussion, comments. It doesn't have a design, it doesn't have a vision, (at least a published one) and it doesn't have a strategy. It desperately needs it.

TAR is such a mission-critical piece of everyday life it deserves the full-send.

Here is my first crack at a vision statement, problem statement, and principles:

Vision Statement

GNU and BSD tar are aging pieces of software that are in need of a new foundation to support a changing world while also so important that backwards and cross compatibility is not implied it is demanded. UUtils is rebuilding tar in Rust to create a modern, maintainable, and memory safe implementation of this critical backbone utility.

Current Problem Statement

Both BSD and GNU tar are tightly coupled and rely on extensive logic to process options and achieve the requested user input. As new archive formats, compression algorithms, and operating system versions have debuted both GNU and BSD tar have had pains keeping up, if it weren't for the mythical efforts of their current maintainers tar would come to a grinding halt. Recently nearly all versions of tar have been the subject of a critical CVE, including Rust based versions tokio-tar and async-tar. The wide spread adoption and exploitation of tar has uncovered that the fundamental versions of this utility are starting to suffer from the weight of their legacy. Making not only engineering experience but even sometimes simple needed changes, painful.

Engineering Principles

  • Each operation mode and option should be independent and be dependent only on shared tooling and utilities
  • Readability over complexity is paramount
  • Backwards and legacy compatibility must be maintained
  • Releases are tested and reviewed with backwards compatibility serving as a regression baseline
  • Rust Unsafe usage requires discussion and approval

These are incomplete but I really just want us to decide on a direction. Again I am really welcoming feedback and input on this. We need to get some guardrails and direction so we can foster the support and acquire hands to help carry the load.

@sylvestre @cakebaker would also love you two to weigh in.

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.

4 participants