Skip to content

feat: add --split-options option#168

Merged
k9withabone merged 2 commits intomainfrom
split-options
Jan 28, 2026
Merged

feat: add --split-options option#168
k9withabone merged 2 commits intomainfrom
split-options

Conversation

@k9withabone
Copy link
Copy Markdown
Member

Added a -s, --split-options option that allows the user to specify Quadlet options that should be split onto multiple lines. By default, Podlet combines all Quadlet options that can be into a space separated list.

For example, podlet podman run -e ONE=one -e TWO=two image results in:

# image.container
[Container]
Environment=ONE=one TWO=two
Image=image

While podlet -s Environment podman run -e ONE=one -e TWO=two image results in:

# image.container
[Container]
Environment=ONE=one
Environment=TWO=two
Image=image

Implementing this required some refactoring of how podlet::serde::quadlet::Serializer works, see the commit messages for details.

This is a draft PR until I get CI working again. I will be creating and merging a branch to update dependencies, make Clippy fixes, and add a MSRV policy. Then I'll rebase this branch and it'll be ready for review.

Closes: #118

@k9withabone k9withabone added this to the v0.3.1 milestone Jan 20, 2026
@k9withabone k9withabone added the enhancement New feature or request label Jan 20, 2026
@k9withabone k9withabone linked an issue Jan 20, 2026 that may be closed by this pull request
@TheRealBecks TheRealBecks removed this from the v0.3.1 milestone Jan 26, 2026
@k9withabone k9withabone force-pushed the split-options branch 2 times, most recently from 0791cd5 to b846cc5 Compare January 26, 2026 19:28
@k9withabone k9withabone marked this pull request as ready for review January 26, 2026 19:35
@k9withabone
Copy link
Copy Markdown
Member Author

@cgzones Do you want to test this out to see if it matches your expectations?

@TheRealBecks TheRealBecks removed the enhancement New feature or request label Jan 27, 2026
Comment thread src/quadlet.rs
Changed `podlet::serde::quadlet::Serializer` to accept sequences and
tuples in addition to structs. Elements in a sequence are serialized as
separate sections. Tuples are combined into a single section (for
combining `podlet::quadlet::Resource` and `podlet::quadlet::Globals`).

Added `impl Serialize for podlet::quadlet::File`, serializing it as a
sequence.

Changed `impl Display for podlet::quadlet::File` to use the new
`Serialize` impl.

Removed `Display` impls from all of
`podlet::{cli::{Service, Unit}, quadlet::{Build, Container, Globals,
Image, Install, Kube, Network, Pod, Resource, Volume}}` as they are no
longer used.

Signed-off-by: Paul Nettleton <k9@k9withabone.dev>
By default, when generating a Quadlet file, Podlet will combine all
Quadlet options that can be into a space separated list
(e.g., `Environment=ONE=one TWO=two`). The `--split-options` option
allows the user to specify which Quadlet options they would like Podlet
to write on separate lines.

This is achieved by subtracting the given Quadlet options from the set
of all Quadlet options that can be joined together and passing the
resulting set to the serializer. The serializer uses that set to
determine which Quadlet options should be joined together in a space
separated list.

Added `podlet::Cli.split_options` field.

Added `podlet::Cli::SPLIT_OPTIONS_HELP`, the long help for
`--split-options`. Set separately from the field in order to preserve
the formatting of the examples.

Replaced `impl Display for podlet::cli::File` with
`podlet::cli::File::serialize()`.

Replaced `impl Display for podlet::cli::k8s::File` with
`podlet::cli::k8s::File::serialize_to_yaml()`.

Replaced `impl Display for podlet::quadlet::File` with
`podlet::quadlet::File::serialize_to_quadlet()`.

Added `podlet::quadlet::JoinOption` enum, which represents all Quadlet
options that can be joined together.

Replaced both of
`podlet::serde::quadlet::{quote_spaces_join_colon(),
quote_spaces_join_space()}` with
`podlet::serde::quadlet::seq_quote_whitespace()` which serializes
a sequence while quoting any values with whitespace.

Changed `podlet::serde::quadlet::to_string()` to take a set of
`podlet::quadlet::JoinOption`s.

Added `podlet::serde::quadlet::to_string_join_all()` as a shortcut to
use in tests.

Changed `podlet::serde::quadlet::ValueSerializer` to use the added
`podlet::serde::quadlet::SeqValueSerializer` to serialize sequences.
`SeqValueSerializer` is where it's decided whether to serialize a
sequence as a single space separated line or as multiple key-value
pairs.

Closes: #118
Signed-off-by: Paul Nettleton <k9@k9withabone.dev>
Copy link
Copy Markdown
Collaborator

@TheRealBecks TheRealBecks left a comment

Choose a reason for hiding this comment

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

LGTM

@k9withabone k9withabone merged commit 2e9898d into main Jan 28, 2026
15 checks passed
@k9withabone k9withabone deleted the split-options branch January 28, 2026 20:57
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.

Add option to split joined Quadlet options

2 participants