Skip to main content

configure_localized_command

Function configure_localized_command 

Source
pub fn configure_localized_command(cmd: Command) -> Command
Expand description

Configures a clap Command with proper localization and color settings.

This function sets up a Command with:

  • Appropriate color settings based on environment variables (NO_COLOR, CLICOLOR_FORCE, etc.)
  • Localized help template with proper formatting
  • TTY detection for automatic color enabling/disabling

§Arguments

  • cmd - The clap Command to configure

§Returns

The configured Command with localization and color settings applied.

§Environment Variables

The following environment variables affect color output:

  • NO_COLOR - Disables all color output
  • CLICOLOR_FORCE or FORCE_COLOR - Forces color output even when not in a TTY
  • TERM - If set to “dumb”, colors are disabled in auto mode

§Examples

use clap::Command;
use uucore::clap_localization::configure_localized_command;

let cmd = Command::new("myutil")
    .arg(clap::Arg::new("input").short('i'));
let configured_cmd = configure_localized_command(cmd);