Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(container): support short flag -h for podman run --hostname #125

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use std::{
path::{Path, PathBuf},
};

use clap::{builder::TypedValueParser, Parser, Subcommand};
use clap::{builder::TypedValueParser, ArgAction, Parser, Subcommand};
use color_eyre::{
eyre::{ensure, eyre, WrapErr},
Help,
Expand Down Expand Up @@ -399,6 +399,7 @@ enum PodmanCommands {
///
/// For details on options see:
/// https://docs.podman.io/en/stable/markdown/podman-systemd.unit.5.html
#[command(disable_help_flag = true)]
Run {
/// The \[Container\] section
#[command(flatten)]
Expand All @@ -407,6 +408,17 @@ enum PodmanCommands {
/// The \[Service\] section
#[command(flatten)]
service: Service,

/// Print help
// Changed from default to support `podman run -h`, i.e. `podman run --hostname`.
#[arg(
short = '?',
long,
action = ArgAction::Help,
help = "Print help (see more with '--help')",
long_help = "Print help (see a summary with '-?')"
)]
help: (),
},

/// Generate a Podman Quadlet `.pod` file
Expand Down
2 changes: 1 addition & 1 deletion src/cli/container/quadlet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ pub struct QuadletOptions {
/// Set the host name that is available inside the container
///
/// Converts to "HostName=NAME"
#[arg(long, value_name = "NAME")]
#[arg(short, long, value_name = "NAME")]
hostname: Option<String>,

/// Specify a static IPv4 address for the container
Expand Down
9 changes: 7 additions & 2 deletions src/cli/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ impl Generate {

/// [`Parser`] for container creation CLI options.
#[derive(Parser, Debug)]
#[command(no_binary_name = true)]
#[command(no_binary_name = true, disable_help_flag = true)]
struct ContainerParser {
/// Podman global options
#[command(flatten)]
Expand Down Expand Up @@ -284,7 +284,7 @@ impl ContainerInspect {

/// [`Parser`] for pod creation CLI options.
#[derive(Parser, Debug)]
#[command(no_binary_name = true)]
#[command(no_binary_name = true, disable_help_flag = true)]
struct PodParser {
/// Podman global options
#[command(flatten)]
Expand Down Expand Up @@ -874,4 +874,9 @@ mod tests {
fn verify_container_parser_cli() {
ContainerParser::command().debug_assert();
}

#[test]
fn verify_pod_parser_cli() {
PodParser::command().debug_assert();
}
}