containers / podlet

Generate Podman Quadlet files from a Podman command, compose file, or existing object
https://crates.io/crates/podlet
Mozilla Public License 2.0
485 stars 13 forks source link

Using -h short flag for —hostname gives podlet’s help instead of generating the correct quadlet #105

Closed xrisk closed 2 weeks ago

xrisk commented 1 month ago
$ podlet podman run -h foo.local hello-world
Generate a Podman Quadlet `.container` file

Usage: podlet podman run [OPTIONS] <IMAGE> [COMMAND]...

Arguments:
  <IMAGE>       The image to run in the container
  [COMMAND]...  Optionally, the command to run in the container

Options:
      --cap-add <CAPABILITY>                                         Add Linux capabilities
      --device <HOST-DEVICE[:CONTAINER-DEVICE][:PERMISSIONS]>        Add a device node from the host into the container
      --annotation <KEY=VALUE>                                       Add an annotation to the container
      --name <NAME>                                                  The (optional) name of the container
      --dns <IP_ADDRESS>                                             Set custom DNS servers
      --dns-option <OPTION>                                          Set custom DNS options
      --dns-search <DOMAIN>
…

Using the —hostname full form makes this work as expected:

podlet podman run --hostname foo.local hello-world
# hello-world.container
[Container]
HostName=foo.local
Image=hello-world
k9withabone commented 1 month ago

I'm not sure what the correct solution for this problem is. I think Docker/Podman made a mistake not reserving -h for help. One possibility is to use Command::disable_help_flag() for podlet podman run and add --help back manually, but then how would one get the short help?

ananthb commented 1 month ago

You could consider just podlet -h to mean the short help and something like podlet --some-option foo --some-other-option bar -h hostname to mean a hostname. It's not great, but its something.

k9withabone commented 1 month ago

Unfortunately, clap (the library being used for command line argument parsing) doesn't work that way. podlet -h podman run and podlet -h both result in the short help for podlet.

k9withabone commented 3 weeks ago

I guess I'll have to use podlet podman run -? for the short help even though it's not a great solution since it makes podlet podman run work different from every other Podlet command.