Skip to main content

gor/
lib.rs

1//! # gor — GitHub on Rust
2//!
3//! A fast, self-contained GitHub CLI written in Rust. Equivalent to `gh` but
4//! with no external dependencies on `git` or OpenSSL.
5//!
6//! ## Architecture
7//!
8//! This crate uses a **library + binary** split:
9//! - `lib.rs` — all business logic, fully unit-testable
10//! - `main.rs` — thin entry point: parse args, init tracing, dispatch
11//!
12//! ## Quick start
13//!
14//! ```rust
15//! use gor::Gor;
16//!
17//! # fn main() -> anyhow::Result<()> {
18//! let app = Gor::new();
19//! // app.run() would parse args and dispatch
20//! # Ok(())
21//! # }
22//! ```
23//!
24//! ## Feature flags
25//!
26//! Currently there are no feature flags. All functionality is included by default.
27
28#![deny(missing_docs)]
29#![deny(unsafe_code)]
30
31pub mod auth;
32pub mod cli;
33pub mod client;
34pub mod cmd;
35pub mod config;
36pub mod error;
37pub mod host;
38pub mod keyring_store;
39pub mod output;
40pub mod repository;
41
42use clap::Parser;
43use cli::Args;
44
45/// The main application entry point for the library.
46///
47/// Construct with [`Gor::new`] and call [`Gor::run`] to execute.
48///
49/// # Examples
50///
51/// ```no_run
52/// use gor::Gor;
53///
54/// let app = Gor::new();
55/// // app.run() parses CLI args and dispatches to the appropriate command
56/// ```
57pub struct Gor;
58
59impl Gor {
60    /// Create a new `Gor` application instance.
61    #[must_use]
62    pub const fn new() -> Self {
63        Self
64    }
65
66    /// Parse CLI arguments and run the requested command.
67    ///
68    /// # Errors
69    ///
70    /// Returns an error if argument parsing fails or if the command execution fails.
71    pub fn run(self) -> anyhow::Result<()> {
72        let args = Args::parse();
73        cmd::dispatch(args)
74    }
75}
76
77impl Default for Gor {
78    fn default() -> Self {
79        Self::new()
80    }
81}
82
83#[cfg(test)]
84mod tests {
85    use super::*;
86    use std::mem::size_of_val;
87
88    #[test]
89    fn gor_new_creates_instance() {
90        let app = Gor::new();
91        // Unit struct — verify it exists and has zero size.
92        assert_eq!(size_of_val(&app), 0);
93    }
94}