cli.rs

Overview

This file implements the command-line interface (CLI) for the Acki Nacki Proxy Manager. It leverages the clap crate to define and parse command-line arguments and subcommands, enabling users to interact with and configure the proxy manager through a structured CLI. The CLI supports specifying a proxy configuration file and executing subcommands related to Docker integration and process ID (PID) management.

Detailed Components

Static Variable: LONG_VERSION

pub static LONG_VERSION: LazyLock<String>

Struct: CliArgs

#[derive(Parser, Debug, Clone)]
pub struct CliArgs {
    pub proxy_config: PathBuf,
    pub command: Command,
}
proxy-manager -c ./myproxy.yaml docker --socket unix:///var/run/docker.sock --container mycontainer

This command sets the proxy configuration file to ./myproxy.yaml and runs the docker subcommand with specified socket and container.

Enum: Command

#[derive(Subcommand, Debug, Clone)]
pub enum Command {
    Docker { socket: String, container: String },
    PidPath { pid_path: PathBuf },
    Pid { pid: u64 },
}

Implementation Details

Interaction with Other System Components


Diagram: CLI Structure and Relationships

classDiagram
class CliArgs {
+proxy_config: PathBuf
+command: Command
}
class Command {
<<enum>>
+Docker
+PidPath
+Pid
}
class Docker {
+socket: String
+container: String
}
class PidPath {
+pid_path: PathBuf
}
class Pid {
+pid: u64
}
CliArgs "1" --> "1" Command
Command <|-- Docker
Command <|-- PidPath
Command <|-- Pid