Skip to content

Commit

Permalink
Clap subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
Zabot committed Sep 3, 2023
1 parent 94a7e7b commit 832f132
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 2 deletions.
107 changes: 107 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ futures = "0.3.28"
parking_lot = "0.12.1"
tokio-stream = "0.1.14"
thiserror = "1.0.47"
clap = {version = "4.4.2", features = ["derive"]}
24 changes: 22 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use std::path::PathBuf;
use std::sync::Arc;

use anyhow::{Context, Result};
use clap::{Parser, Subcommand};
use git2::Repository;
use std::sync::Arc;

mod auth;
mod config;
Expand All @@ -14,8 +17,25 @@ mod update;
use config::Config;
use stack::Stack;

#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
struct Cli {
#[arg(short = 'C', value_name = "path")]
path: PathBuf,

#[command(subcommand)]
command: Commands,
}

#[derive(Subcommand, Debug)]
enum Commands {
Submit,
}

#[tokio::main]
async fn main() -> Result<()> {
let cli = Cli::parse();

let config = Config::load().context("failed to load config")?;
tracing_subscriber::fmt::init();

Expand All @@ -39,7 +59,7 @@ async fn main() -> Result<()> {
);
}

let repo = Repository::discover("test").context("failed to open repo")?;
let repo = Repository::discover(&cli.path).context("failed to open repo")?;

// Push every commit
let octocrab = Arc::new(
Expand Down

0 comments on commit 832f132

Please sign in to comment.