docs: add comments to src/main.rs

This commit is contained in:
Andrew Phillips (aider)
2025-05-21 20:19:09 -03:00
parent 9af7af4687
commit 894a893536

View File

@@ -46,6 +46,9 @@ lazy_static! {
.build();
}
/**
* Main struct for command-line arguments.
*/
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
pub struct Args {
@@ -60,6 +63,9 @@ pub struct Args {
ids_or_tags: Vec<NumberOrString>,
}
/**
* Struct for mode-specific arguments.
*/
#[derive(Parser, Debug)]
struct ModeArgs {
#[arg(group("mode"), help_heading("Mode Options"), short, long, conflicts_with_all(["get", "diff", "list", "update", "delete", "info", "status"]))]
@@ -99,6 +105,9 @@ struct ModeArgs {
status: bool,
}
/**
* Struct for item-specific arguments.
*/
#[derive(Parser, Debug)]
struct ItemArgs {
#[arg(help_heading("Item Options"), short, long, conflicts_with_all(["get", "delete", "status"]))]
@@ -116,6 +125,9 @@ struct ItemArgs {
compression: Option<String>,
}
/**
* Struct for general options.
*/
#[derive(Parser, Debug)]
struct OptionsArgs {
#[arg(long, env("KEEP_DIR"))]
@@ -143,6 +155,9 @@ struct OptionsArgs {
quiet: bool,
}
/**
* Enum representing the different modes of operation.
*/
#[derive(Debug, PartialEq)]
enum KeepModes {
Unknown,
@@ -156,6 +171,9 @@ enum KeepModes {
Status,
}
/**
* Struct for key-value pairs.
*/
#[derive(Debug, Clone)]
struct KeyValue {
key: String,
@@ -175,6 +193,9 @@ impl FromStr for KeyValue {
}
}
/**
* Enum for representing either a number or a string.
*/
#[derive(Debug, Clone)]
enum NumberOrString {
Number(i64),
@@ -190,6 +211,9 @@ impl FromStr for NumberOrString {
}
}
/**
* Main function to handle command-line arguments and execute the appropriate mode.
*/
fn main() -> Result<(), Error> {
use std::fs;
let proj_dirs = ProjectDirs::from("gt0.ca", "Andrew Phillips", "Keep");