Add scaffolding for problems
This commit is contained in:
parent
fe6eab5b8c
commit
75f2a5ce70
4 changed files with 516 additions and 1 deletions
34
src/main.rs
34
src/main.rs
|
|
@ -1 +1,33 @@
|
|||
fn main() {}
|
||||
use clap::{Parser, Subcommand};
|
||||
use enum_dispatch::enum_dispatch;
|
||||
|
||||
mod one;
|
||||
|
||||
#[derive(Parser)]
|
||||
struct GlobalArgs {}
|
||||
|
||||
#[derive(Parser)]
|
||||
struct Args {
|
||||
#[clap(subcommand)]
|
||||
problem: Problems,
|
||||
#[clap(flatten)]
|
||||
global: GlobalArgs,
|
||||
}
|
||||
|
||||
#[enum_dispatch]
|
||||
trait Problem {
|
||||
fn solve(self, args: GlobalArgs) -> color_eyre::Result<()>;
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
#[enum_dispatch(Problem)]
|
||||
enum Problems {
|
||||
#[clap(name = "1")]
|
||||
One(one::Args),
|
||||
}
|
||||
|
||||
fn main() -> color_eyre::Result<()> {
|
||||
color_eyre::install()?;
|
||||
let args = Args::parse();
|
||||
args.problem.solve(args.global)
|
||||
}
|
||||
|
|
|
|||
10
src/one.rs
Normal file
10
src/one.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
use crate::{GlobalArgs, Problem};
|
||||
|
||||
#[derive(clap::Parser)]
|
||||
pub struct Args {}
|
||||
|
||||
impl Problem for Args {
|
||||
fn solve(self, _: GlobalArgs) -> color_eyre::Result<()> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue