cli.rs

Overview

This file defines the command-line interface (CLI) argument parsing for the Acki-Nacki Block Manager component. It leverages the clap crate to provide a structured way to specify and validate runtime parameters required for the application. The primary purpose of this file is to declare the configurable inputs related to network endpoints and storage paths that the block manager will use to operate.

The file also defines a static constant LONG_VERSION that aggregates build metadata such as the package version, Git branch, commit, and build date/time, which is embedded into the CLI help/version output.


Detailed Explanation

Static Variable: LONG_VERSION

pub static LONG_VERSION: LazyLock<String>

This information is injected at compile time via environment variables and used to display extended version information in CLI outputs.

Usage Example

your_binary --version

The output includes the detailed build info from LONG_VERSION.


Struct: Args

#[derive(Parser, Debug)]
pub struct Args

Fields

Field Name

Type

Description

CLI Argument / Env Variable

Default Value

stream_src_url

url::Url

URL of the HTTP/3 server for data streaming. Must use HTTPS with an explicit port specified.

--stream-src-url / env

Required (no default)

http_src_url

url::Url

URL of the node HTTP endpoint for node communication.

--http-src-url / env

Required (no default)

rest_api

std::net::SocketAddr

Socket address where the REST API will listen.

--rest-api / env

0.0.0.0:8001

sqlite_path

std::path::PathBuf

File system path to the SQLite database file used for storage.

--sqlite-path / env

Required (no default)

Example CLI Usage

your_binary \
  --stream-src-url=https://example.com:443 \
  --http-src-url=http://node-endpoint:8080 \
  --rest-api=127.0.0.1:9000 \
  --sqlite-path=/var/lib/db.sqlite

This command instructs the application to connect to the specified HTTP/3 server, node HTTP endpoint, bind the REST API to the given address, and use the given SQLite file for persistent storage.


Implementation Details


Interaction with Other Parts of the System


Diagram: Structure of cli.rs

classDiagram
class Args {
+stream_src_url: Url
+http_src_url: Url
+rest_api: SocketAddr
+sqlite_path: PathBuf
}
class LONG_VERSION {
<<static>>
+String
}
Args ..> Url : uses
Args ..> SocketAddr : uses
Args ..> PathBuf : uses
LONG_VERSION <|-- LazyLock : initialized by

This diagram shows the primary data structure Args with its fields and the static LONG_VERSION lazy-initialized string, highlighting their relationships to standard types used for URL, socket address, and file paths.