use std::str::FromStr;
use clap::{ArgAction, Parser};
use crate::options;
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub enum LayoutAlgorithm {
None,
Dot,
Neato,
Twopi,
Circo,
Fdp,
Sfdp,
}
impl FromStr for LayoutAlgorithm {
type Err = &'static str;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"none" => Ok(Self::None),
"dot" => Ok(Self::Dot),
"neato" => Ok(Self::Neato),
"twopi" => Ok(Self::Twopi),
"circo" => Ok(Self::Circo),
"fdp" => Ok(Self::Fdp),
"sfdp" => Ok(Self::Sfdp),
_ => Err("Unrecognized layout"),
}
}
}
impl ToString for LayoutAlgorithm {
fn to_string(&self) -> String {
match self {
Self::None => "none",
Self::Dot => "dot",
Self::Neato => "neato",
Self::Twopi => "twopi",
Self::Circo => "circo",
Self::Fdp => "fdp",
Self::Sfdp => "sfdp",
}
.to_owned()
}
}
#[derive(Parser, Clone, PartialEq, Eq, Debug)]
#[group(id = "GenerateSelectionOptions")]
pub struct Options {
#[command(flatten)]
pub general: options::general::Options,
#[command(flatten)]
pub project: options::project::Options,
#[command(flatten)]
pub selection: options::selection::Options,
#[arg(long = "acyclic", action = ArgAction::SetTrue, conflicts_with = "focus_on")]
pub acyclic: bool,
#[arg(long = "layout", default_value = "neato")]
pub layout: LayoutAlgorithm,
#[clap(long = "no-modules", action = ArgAction::SetFalse)]
pub modules: bool,
#[clap(long = "modules", action = ArgAction::SetTrue, overrides_with = "modules")]
pub no_modules: (),
#[arg(long = "uses")]
pub uses: bool,
#[arg(long = "no-uses", action = ArgAction::SetFalse, overrides_with = "uses")]
pub no_uses: (),
#[arg(long = "externs")]
pub externs: bool,
#[arg(long = "no-externs", action = ArgAction::SetFalse, overrides_with = "externs")]
pub no_externs: (),
}