Add dummy parameter parsing to cucumber

This commit is contained in:
Dennis 2024-05-30 16:14:58 +02:00
parent 6faa5f45e8
commit 63c9d599f9
No known key found for this signature in database
GPG Key ID: 6937EAEA33A3FA5D
3 changed files with 57 additions and 1 deletions

1
Cargo.lock generated
View File

@ -654,6 +654,7 @@ version = "0.1.0"
dependencies = [
"cheap-ruler",
"chksum-md5",
"clap",
"cucumber",
"futures",
"geo-types",

View File

@ -6,6 +6,7 @@ edition = "2021"
[dependencies]
cheap-ruler = "0.4.0"
chksum-md5 = "0.0.0"
clap = "4.5.4"
cucumber = "0.21.0"
futures = "0.3.30"
geo-types = "0.7.13"

View File

@ -1,13 +1,18 @@
extern crate clap;
mod osm;
use core::panic;
use std::collections::{HashMap, HashSet, VecDeque};
use std::error::Error;
use std::fs::{create_dir_all, DirEntry, File};
use std::io::{self, Read, Write};
use std::path::PathBuf;
use std::{env, fs};
use std::str::FromStr;
use std::{env, fmt, fs};
use cheap_ruler::CheapRuler;
use clap::{Arg, Parser};
use cucumber::{self, gherkin::Step, given, when, World};
use futures::{future, FutureExt};
use geo_types::{point, Point};
@ -280,7 +285,56 @@ impl Iterator for LexicographicFileWalker {
}
}
#[derive( clap::ValueEnum, Clone, Default, Debug)]
enum LoadMethod {
Mmap,
#[default]
Datastore,
Directly,
}
impl ToString for LoadMethod {
fn to_string(&self) -> String {
match self {
LoadMethod::Mmap => "mmap".into(),
LoadMethod::Datastore => "datastore".into(),
LoadMethod::Directly => "directly".into(),
}
}
}
#[derive(clap::ValueEnum, Clone, Default, Debug)]
enum RoutingAlgorithm {
#[default]
CH,
MLD,
}
impl ToString for RoutingAlgorithm {
fn to_string(&self) -> String {
match self {
RoutingAlgorithm::CH => "ch".into(),
RoutingAlgorithm::MLD => "mld".into(),
}
}
}
// TODO: move to external file
#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
struct Args {
// underlying memory storage
#[arg(short, default_value_t = LoadMethod::Datastore)]
memory: LoadMethod,
// Number of times to greet
#[arg(short, default_value_t = RoutingAlgorithm::CH)]
p: RoutingAlgorithm,
}
fn main() {
let args = Args::parse();
println!("name: {:?}", args);
// create OSRM digest before any tests are executed since cucumber-rs doesn't have @beforeAll
let exe_path = env::current_exe().expect("failed to get current exe path");
let path = exe_path