This module provides the command-line interface for the wget-rs application. It defines the structure of supported flags and arguments using the clap crate.
-
Argument parsing using
#[derive(Parser)] -
Manual validation via
Cli::validate() -
Support for standard and advanced wget-like flags:
-
URLs and input files
-
Output filename (
-O) and download directory (-P) -
Background mode (
-B) -
Rate limiting (
--rate-limit) -
Website mirroring (
--mirror) with additional filters:- File type reject list (
-R) - Excluded directories (
-X) - Offline link conversion (
--convert-links)
- File type reject list (
-
cli/args.rs: Defines theClistruct and its fields usingclapcli/mod.rs: Exports theClistruct for external use
In main.rs:
use clap::Parser;
use crate::cli::Cli;
fn main() {
let args = Cli::parse();
args.validate().expect("Invalid arguments");
// Application logic follows
}Cli::parse()comes from theParsertrait, so be sure touse clap::ParserCli::validate()provides additional checks not enforced byclap, like ensuring paths exist or validating rate formats
This module aims to keep CLI parsing declarative, clean, and aligned with real-world usage of wget.