Skip to content

Commit 0b70d12

Browse files
committed
fix(container): support short flag -h for podman run --hostname
Changed short help flag to `-?` for `podlet podman run`. This could be a potentially minor breaking change for some users. Fixes: #105 Signed-off-by: Paul Nettleton <[email protected]>
1 parent 8ef9420 commit 0b70d12

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

src/cli.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use std::{
2626
path::{Path, PathBuf},
2727
};
2828

29-
use clap::{builder::TypedValueParser, Parser, Subcommand};
29+
use clap::{builder::TypedValueParser, ArgAction, Parser, Subcommand};
3030
use color_eyre::{
3131
eyre::{ensure, eyre, WrapErr},
3232
Help,
@@ -399,6 +399,7 @@ enum PodmanCommands {
399399
///
400400
/// For details on options see:
401401
/// https://docs.podman.io/en/stable/markdown/podman-systemd.unit.5.html
402+
#[command(disable_help_flag = true)]
402403
Run {
403404
/// The \[Container\] section
404405
#[command(flatten)]
@@ -407,6 +408,17 @@ enum PodmanCommands {
407408
/// The \[Service\] section
408409
#[command(flatten)]
409410
service: Service,
411+
412+
/// Print help
413+
// Changed from default to support `podman run -h`, i.e. `podman run --hostname`.
414+
#[arg(
415+
short = '?',
416+
long,
417+
action = ArgAction::Help,
418+
help = "Print help (see more with '--help')",
419+
long_help = "Print help (see a summary with '-?')"
420+
)]
421+
help: (),
410422
},
411423

412424
/// Generate a Podman Quadlet `.pod` file

src/cli/container/quadlet.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ pub struct QuadletOptions {
230230
/// Set the host name that is available inside the container
231231
///
232232
/// Converts to "HostName=NAME"
233-
#[arg(long, value_name = "NAME")]
233+
#[arg(short, long, value_name = "NAME")]
234234
hostname: Option<String>,
235235

236236
/// Specify a static IPv4 address for the container

src/cli/generate.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ impl Generate {
164164

165165
/// [`Parser`] for container creation CLI options.
166166
#[derive(Parser, Debug)]
167-
#[command(no_binary_name = true)]
167+
#[command(no_binary_name = true, disable_help_flag = true)]
168168
struct ContainerParser {
169169
/// Podman global options
170170
#[command(flatten)]
@@ -284,7 +284,7 @@ impl ContainerInspect {
284284

285285
/// [`Parser`] for pod creation CLI options.
286286
#[derive(Parser, Debug)]
287-
#[command(no_binary_name = true)]
287+
#[command(no_binary_name = true, disable_help_flag = true)]
288288
struct PodParser {
289289
/// Podman global options
290290
#[command(flatten)]
@@ -874,4 +874,9 @@ mod tests {
874874
fn verify_container_parser_cli() {
875875
ContainerParser::command().debug_assert();
876876
}
877+
878+
#[test]
879+
fn verify_pod_parser_cli() {
880+
PodParser::command().debug_assert();
881+
}
877882
}

0 commit comments

Comments
 (0)