-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
57 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
macro_rules! mk_subcommand { | ||
($($variant:ident => $module:ident),* $(,)?) => { | ||
$(mod $module;)* | ||
|
||
#[derive(::clap::Subcommand, Debug)] | ||
pub enum Command { | ||
$($variant($module::Args),)* | ||
} | ||
|
||
#[derive(::clap::Parser, Debug)] | ||
pub struct Args { | ||
#[clap(subcommand)] | ||
command: Command, | ||
} | ||
|
||
pub fn run(args: Args) -> ::anyhow::Result<()> { | ||
match args.command { | ||
$(Command::$variant(args) => $module::run(args),)* | ||
} | ||
} | ||
}; | ||
} | ||
|
||
pub(crate) use mk_subcommand; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
pub(crate) mod amazons; | ||
pub(crate) mod canonical_form; | ||
pub(crate) mod domineering; | ||
pub(crate) mod quicksort; | ||
pub(crate) mod snort; | ||
pub(crate) mod wind_up; | ||
crate::clap_utils::mk_subcommand! { | ||
Domineering => domineering, | ||
Snort => snort, | ||
Quicksort => quicksort, | ||
WindUp => wind_up, | ||
CanonicalForm => canonical_form, | ||
Amazons => amazons, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,3 @@ | ||
use anyhow::Result; | ||
use clap::{self, Parser, Subcommand}; | ||
|
||
mod evaluate; | ||
|
||
#[derive(Subcommand, Debug)] | ||
pub enum Command { | ||
Evaluate(evaluate::Args), | ||
} | ||
|
||
#[derive(Parser, Debug)] | ||
pub struct Args { | ||
#[clap(subcommand)] | ||
pub command: Command, | ||
} | ||
|
||
pub fn run(args: Args) -> Result<()> { | ||
match args.command { | ||
Command::Evaluate(args) => evaluate::run(args), | ||
} | ||
crate::clap_utils::mk_subcommand! { | ||
Evaluate => evaluate, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,3 @@ | ||
use anyhow::Result; | ||
use clap::{self, Parser, Subcommand}; | ||
|
||
mod sum; | ||
|
||
#[derive(Subcommand, Debug)] | ||
pub enum Command { | ||
Sum(sum::Args), | ||
} | ||
|
||
#[derive(Parser, Debug)] | ||
pub struct Args { | ||
#[clap(subcommand)] | ||
pub command: Command, | ||
} | ||
|
||
pub fn run(args: Args) -> Result<()> { | ||
match args.command { | ||
Command::Sum(args) => sum::run(args), | ||
} | ||
crate::clap_utils::mk_subcommand! { | ||
Sum => sum, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,8 @@ | ||
use anyhow::Result; | ||
use clap::{self, Parser, Subcommand}; | ||
|
||
mod common; | ||
mod evaluate; | ||
mod exhaustive_search; | ||
mod genetic_search; | ||
mod latex_table; | ||
|
||
#[derive(Subcommand, Debug)] | ||
pub enum Command { | ||
ExhaustiveSearch(exhaustive_search::Args), | ||
GeneticSearch(genetic_search::Args), | ||
Evaluate(evaluate::Args), | ||
LatexTable(latex_table::Args), | ||
} | ||
|
||
#[derive(Parser, Debug)] | ||
pub struct Args { | ||
#[clap(subcommand)] | ||
pub command: Command, | ||
} | ||
|
||
pub fn run(args: Args) -> Result<()> { | ||
match args.command { | ||
Command::ExhaustiveSearch(args) => exhaustive_search::run(args), | ||
Command::GeneticSearch(args) => genetic_search::run(args), | ||
Command::Evaluate(args) => evaluate::run(args), | ||
Command::LatexTable(args) => latex_table::run(args), | ||
} | ||
crate::clap_utils::mk_subcommand! { | ||
ExhaustiveSearch => exhaustive_search, | ||
GeneticSearch => genetic_search, | ||
Evaluate => evaluate, | ||
LatexTable => latex_table, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,3 @@ | ||
use anyhow::Result; | ||
use clap::{self, Parser, Subcommand}; | ||
|
||
mod range; | ||
|
||
#[derive(Subcommand, Debug)] | ||
pub enum Command { | ||
Range(range::Args), | ||
} | ||
|
||
#[derive(Parser, Debug)] | ||
pub struct Args { | ||
#[clap(subcommand)] | ||
pub command: Command, | ||
} | ||
|
||
pub fn run(args: Args) -> Result<()> { | ||
match args.command { | ||
Command::Range(args) => range::run(args), | ||
} | ||
crate::clap_utils::mk_subcommand! { | ||
Range => range, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,8 @@ | ||
use anyhow::Result; | ||
use clap::{self, Parser, Subcommand}; | ||
|
||
mod common; | ||
pub mod genetic; | ||
pub mod graph; | ||
pub mod latex; | ||
pub mod three_caterpillar; | ||
|
||
#[derive(Subcommand, Debug)] | ||
pub enum Command { | ||
Genetic(genetic::Args), | ||
Latex(latex::Args), | ||
Graph(graph::Args), | ||
ThreeCaterpillar(three_caterpillar::Args), | ||
} | ||
|
||
#[derive(Parser, Debug)] | ||
pub struct Args { | ||
#[clap(subcommand)] | ||
pub command: Command, | ||
} | ||
|
||
pub fn run(args: Args) -> Result<()> { | ||
match args.command { | ||
Command::Genetic(args) => genetic::run(args), | ||
Command::Latex(args) => latex::run(args), | ||
Command::Graph(args) => graph::run(args), | ||
Command::ThreeCaterpillar(args) => three_caterpillar::run(args), | ||
} | ||
crate::clap_utils::mk_subcommand! { | ||
Genetic => genetic, | ||
Latex => latex, | ||
Graph => graph, | ||
ThreeCaterpillar => three_caterpillar, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,3 @@ | ||
use anyhow::Result; | ||
use clap::{self, Parser, Subcommand}; | ||
|
||
mod range; | ||
|
||
#[derive(Subcommand, Debug)] | ||
pub enum Command { | ||
Range(range::Args), | ||
} | ||
|
||
#[derive(Parser, Debug)] | ||
pub struct Args { | ||
#[clap(subcommand)] | ||
pub command: Command, | ||
} | ||
|
||
pub fn run(args: Args) -> Result<()> { | ||
match args.command { | ||
Command::Range(args) => range::run(args), | ||
} | ||
crate::clap_utils::mk_subcommand! { | ||
Range => range, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,16 @@ | ||
use crate::commands::*; | ||
use anyhow::Result; | ||
use clap::{self, Parser, Subcommand}; | ||
use clap::Parser; | ||
|
||
pub(crate) mod clap_utils; | ||
mod commands; | ||
mod io; | ||
|
||
#[cfg(not(windows))] | ||
#[global_allocator] | ||
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; | ||
|
||
#[derive(Subcommand, Debug)] | ||
enum Command { | ||
Domineering(domineering::Args), | ||
Snort(snort::Args), | ||
Quicksort(quicksort::Args), | ||
WindUp(wind_up::Args), | ||
CanonicalForm(canonical_form::Args), | ||
Amazons(amazons::Args), | ||
} | ||
|
||
#[derive(Parser)] | ||
struct Args { | ||
#[clap(subcommand)] | ||
command: Command, | ||
} | ||
|
||
fn main() -> Result<()> { | ||
let args = Args::parse(); | ||
match args.command { | ||
Command::Domineering(args) => domineering::run(args), | ||
Command::Snort(args) => snort::run(args), | ||
Command::Quicksort(args) => quicksort::run(args), | ||
Command::WindUp(args) => wind_up::run(args), | ||
Command::CanonicalForm(args) => canonical_form::run(args), | ||
Command::Amazons(args) => amazons::run(args), | ||
} | ||
crate::commands::run(args) | ||
} |