remove unneccessary cmdargs feature
This commit is contained in:
parent
d20a2d29fd
commit
cc3da89aee
@ -25,28 +25,3 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
command: build
|
command: build
|
||||||
args: --release --no-default-features --features "custom_pieces"
|
args: --release --no-default-features --features "custom_pieces"
|
||||||
build_cmdargs:
|
|
||||||
name: Saltfish [cmdargs]
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- uses: actions-rs/toolchain@v1
|
|
||||||
with:
|
|
||||||
toolchain: stable
|
|
||||||
- uses: actions-rs/cargo@v1
|
|
||||||
with:
|
|
||||||
command: build
|
|
||||||
args: --release --no-default-features --features "cmdargs"
|
|
||||||
build_cmdargs_custom_pieces:
|
|
||||||
name: Saltfish [cmdargs custom_pieces]
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- uses: actions-rs/toolchain@v1
|
|
||||||
with:
|
|
||||||
toolchain: stable
|
|
||||||
- uses: actions-rs/cargo@v1
|
|
||||||
with:
|
|
||||||
command: build
|
|
||||||
args: >
|
|
||||||
--release --no-default-features --features "cmdargs custom_pieces"
|
|
||||||
|
|||||||
@ -4,13 +4,11 @@ version = "0.1.0"
|
|||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["cmdargs"]
|
|
||||||
custom_pieces = []
|
custom_pieces = []
|
||||||
cmdargs = ["dep:clap"]
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
toml = { version = "0.8.12" }
|
toml = { version = "0.8.12" }
|
||||||
clap = { version = "4.5.4", features = ["derive"], optional = true }
|
clap = { version = "4.5.4", features = ["derive"] }
|
||||||
serde = { version = "1.0.197", features = ["derive"] }
|
serde = { version = "1.0.197", features = ["derive"] }
|
||||||
serde_derive = { version = "1.0.197" }
|
serde_derive = { version = "1.0.197" }
|
||||||
num_cpus = "1.16.0"
|
num_cpus = "1.16.0"
|
||||||
|
|||||||
@ -39,4 +39,17 @@ impl Args {
|
|||||||
pub fn get_jobs(self) -> u8 {
|
pub fn get_jobs(self) -> u8 {
|
||||||
self.jobs
|
self.jobs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_ref_depth(&self) -> u8 {
|
||||||
|
self.depth
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_ref_strenght(&self) -> u8 {
|
||||||
|
self.strenght
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_ref_jobs(&self) -> u8 {
|
||||||
|
self.jobs
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,8 @@ use crate::chess::piece::CustomPiece;
|
|||||||
#[cfg(feature = "custom_pieces")]
|
#[cfg(feature = "custom_pieces")]
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
use crate::config::args::Args;
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
struct Engine {
|
struct Engine {
|
||||||
@ -46,4 +48,15 @@ impl Config {
|
|||||||
file.read_to_string(&mut config_string).expect("Failed to parse file to string");
|
file.read_to_string(&mut config_string).expect("Failed to parse file to string");
|
||||||
toml::from_str(&config_string).expect("Failed to parse toml")
|
toml::from_str(&config_string).expect("Failed to parse toml")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn merge_args(self, args: &Args) -> Self {
|
||||||
|
Self {
|
||||||
|
#[cfg(feature = "custom_pieces")]
|
||||||
|
pieces: self.pieces,
|
||||||
|
engine: Some(Engine {
|
||||||
|
depth: Some(args.get_ref_depth()),
|
||||||
|
jobs: Some(args.get_ref_jobs())
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,2 @@
|
|||||||
pub mod config;
|
pub mod config;
|
||||||
|
|
||||||
#[cfg(feature = "cmdargs")]
|
|
||||||
pub mod args;
|
pub mod args;
|
||||||
|
|||||||
18
src/main.rs
18
src/main.rs
@ -5,14 +5,10 @@
|
|||||||
|
|
||||||
|
|
||||||
use config::config::Config;
|
use config::config::Config;
|
||||||
|
|
||||||
#[cfg(feature = "cmdargs")]
|
|
||||||
use config::args::Args;
|
use config::args::Args;
|
||||||
#[cfg(feature = "cmdargs")]
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
// TODO: move all of this into seperate file
|
||||||
|
|
||||||
#[cfg(not(feature = "cmdargs"))]
|
|
||||||
use std::path::Path;
|
|
||||||
|
|
||||||
mod chess;
|
mod chess;
|
||||||
mod config;
|
mod config;
|
||||||
@ -21,17 +17,13 @@ mod config;
|
|||||||
fn main() {
|
fn main() {
|
||||||
let config;
|
let config;
|
||||||
|
|
||||||
#[cfg(feature = "cmdargs")]
|
|
||||||
{
|
|
||||||
// TODO: implement error handling and logging and handle this case appropriate
|
// TODO: implement error handling and logging and handle this case appropriate
|
||||||
let args = Args::try_parse().unwrap_or_else(|err|{println!("error parsing cmd args\n{:#?}", err); Args::default()});
|
let args = Args::try_parse().unwrap_or_else(|err|{
|
||||||
|
println!("error parsing cmd args\n{:#?}", err);
|
||||||
|
Args::default()
|
||||||
|
});
|
||||||
config = Config::read(&args.get_config_path());
|
config = Config::read(&args.get_config_path());
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(not(feature = "cmdargs"))]
|
|
||||||
{
|
|
||||||
config = Config::read(Path::new("./config.toml"));
|
|
||||||
}
|
|
||||||
|
|
||||||
println!("{config:#?}");
|
println!("{config:#?}");
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user