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