`tuist clean` support excluding specific categories

tuist clean already supports cleaning everything, or cleaning only specific categories.

One case I run into is the opposite. I want to clean most things, but keep one category around.

For example, I often want to keep dependencies so SwiftPM packages do not need to be resolved again, while still cleaning the rest.

That means listing every other category manually:

tuist clean plugins generatedAutomationProjects projectDescriptionHelpers manifests editProjects runs binaries selectiveTests

It could be nice to have a small exclusion option for this:

tuist clean --except dependencies
tuist clean -x dependencies

What do you think?

Thanks for proposing this! I like the direction. tuist clean already has the “clean only these categories” path, but the inverse use case is real: “clean almost everything, but keep dependencies” is much easier to express as subtraction.

I asked Codex to help sanity-check this against other CLI conventions, so this reply is partly Codex-generated. The main takeaway was that --exclude seems like the most familiar spelling. For example, git clean already uses -e / --exclude, while -x means something different there, so I’d avoid -x because it can clash with muscle memory from git clean -xdf.

My preference would be:

tuist clean --exclude dependencies
tuist clean --exclude dependencies runs

One implementation detail I’d suggest: make explicit categories and exclusions mutually exclusive. So these would be valid:

tuist clean dependencies
tuist clean --exclude dependencies

but this would fail with a clear usage error:

tuist clean manifests --exclude dependencies

That keeps the mental model simple:

  • positional categories mean “clean only these”
  • --exclude means “clean all except these”

This also avoids users having to keep a long category list up to date as new cleanable categories are introduced.

Thanks, @marekfort.

-e / --exclude sounds better than -x / --except to me as well. :smiley:

I also agree with making positional categories and --exclude mutually exclusive. It keeps the command clear for now and leaves room for cleaner categories later, without forcing users to maintain a long include list.