LCOV - code coverage report
Current view: top level - src - main.rs (source / functions) Coverage Total Hit
Test: Hunky Coverage Lines: 79.3 % 29 23
Test Date: 2026-02-20 16:10:39 Functions: 71.4 % 7 5

            Line data    Source code
       1              : mod app;
       2              : mod git;
       3              : mod ui;
       4              : mod watcher;
       5              : mod diff;
       6              : mod syntax;
       7              : 
       8              : use anyhow::Result;
       9              : use app::App;
      10              : use clap::Parser;
      11              : 
      12              : #[derive(Parser, Debug)]
      13              : #[command(name = "hunky")]
      14              : #[command(about = "A TUI for streaming git changes in real-time", long_about = None)]
      15              : struct Args {
      16              :     /// Path to the git repository to watch
      17              :     #[arg(short, long, default_value = ".")]
      18              :     repo: String,
      19              : }
      20              : 
      21              : #[tokio::main]
      22            0 : async fn main() -> Result<()> {
      23            0 :     let args = Args::parse();
      24              :     
      25              :     // Initialize the application with the specified repository
      26            0 :     let mut app = App::new(&args.repo).await?;
      27              :     
      28              :     // Run the application
      29            0 :     app.run().await?;
      30              :     
      31            0 :     Ok(())
      32            0 : }
      33              : 
      34              : #[cfg(test)]
      35              : mod tests {
      36              :     use super::*;
      37              :     use clap::CommandFactory;
      38              : 
      39              :     #[test]
      40            1 :     fn parses_default_repo_argument() {
      41            1 :         let args = Args::try_parse_from(["hunky"]).expect("args should parse");
      42            1 :         assert_eq!(args.repo, ".");
      43            1 :     }
      44              : 
      45              :     #[test]
      46            1 :     fn parses_explicit_repo_argument() {
      47            1 :         let args = Args::try_parse_from(["hunky", "--repo", "/tmp/custom"]).expect("args should parse");
      48            1 :         assert_eq!(args.repo, "/tmp/custom");
      49            1 :     }
      50              : 
      51              :     #[test]
      52            1 :     fn parses_short_repo_argument() {
      53            1 :         let args = Args::try_parse_from(["hunky", "-r", "/tmp/short"]).expect("args should parse");
      54            1 :         assert_eq!(args.repo, "/tmp/short");
      55            1 :     }
      56              : 
      57              :     #[test]
      58            1 :     fn help_text_mentions_tui_description() {
      59            1 :         let mut help = Vec::new();
      60            1 :         Args::command()
      61            1 :             .write_long_help(&mut help)
      62            1 :             .expect("help should render");
      63            1 :         let help = String::from_utf8(help).expect("help should be utf-8");
      64            1 :         assert!(help.contains("A TUI for streaming git changes in real-time"));
      65            1 :     }
      66              : 
      67              :     #[test]
      68            1 :     fn unknown_argument_returns_error() {
      69            1 :         assert!(Args::try_parse_from(["hunky", "--unknown"]).is_err());
      70            1 :     }
      71              : }
        

Generated by: LCOV version 2.0-1