use clap::{Parser, ValueEnum}; use clap_num::maybe_hex; use vmem::AllocPolicy; #[derive(ValueEnum, Clone, Copy, Debug, Default)] pub enum Policy { #[default] Instant, Best, Next, } impl From for AllocPolicy { fn from(val: Policy) -> Self { match val { Policy::Instant => AllocPolicy::InstantFit, Policy::Best => AllocPolicy::BestFit, Policy::Next => AllocPolicy::NextFit, } } } #[derive(Parser, Debug)] #[command(disable_help_flag = true)] pub enum Command { Create { #[arg(long)] name: String, #[arg(long, value_parser=maybe_hex::)] quantum: usize, }, Delete { #[arg(long)] arena: String, }, AddSpan { #[arg(long)] arena: String, #[arg(long, value_parser=maybe_hex::)] base: usize, #[arg(long, value_parser=maybe_hex::)] size: usize, }, Alloc { #[arg(long)] arena: String, #[arg(long, default_value = "instant")] policy: Policy, #[arg(long, value_parser=maybe_hex::)] size: usize, #[arg(long, value_parser=maybe_hex::)] align: usize, #[arg(long, value_parser=maybe_hex::)] phase: Option, #[arg(long, value_parser=maybe_hex::)] nocross: Option, #[arg(long, value_parser=maybe_hex::)] min: Option, #[arg(long, value_parser=maybe_hex::)] max: Option, }, Free { #[arg(long)] arena: String, #[arg(long, value_parser=maybe_hex::)] base: usize, }, Print { #[arg(long)] arena: Option, }, Exit, }