cargo_modules/command/dependencies/
options.rs1use std::{fmt::Display, str::FromStr};
6
7use clap::Parser;
8
9use crate::options::{GeneralOptions, ProjectOptions};
10
11#[derive(Copy, Clone, PartialEq, Eq, Debug)]
12pub enum LayoutAlgorithm {
13 None,
14 Dot,
15 Neato,
16 Twopi,
17 Circo,
18 Fdp,
19 Sfdp,
20}
21
22impl FromStr for LayoutAlgorithm {
23 type Err = &'static str;
24
25 fn from_str(s: &str) -> Result<Self, Self::Err> {
26 match s {
27 "none" => Ok(Self::None),
28 "dot" => Ok(Self::Dot),
29 "neato" => Ok(Self::Neato),
30 "twopi" => Ok(Self::Twopi),
31 "circo" => Ok(Self::Circo),
32 "fdp" => Ok(Self::Fdp),
33 "sfdp" => Ok(Self::Sfdp),
34 _ => Err("Unrecognized layout"),
35 }
36 }
37}
38
39impl Display for LayoutAlgorithm {
40 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
41 f.write_str(match self {
42 Self::None => "none",
43 Self::Dot => "dot",
44 Self::Neato => "neato",
45 Self::Twopi => "twopi",
46 Self::Circo => "circo",
47 Self::Fdp => "fdp",
48 Self::Sfdp => "sfdp",
49 })
50 }
51}
52
53#[derive(Parser, Clone, PartialEq, Eq, Debug)]
54#[group(id = "GenerateSelectionOptions")]
55pub struct Options {
56 #[command(flatten)]
57 pub general: GeneralOptions,
58
59 #[command(flatten)]
60 pub project: ProjectOptions,
61
62 #[command(flatten)]
63 pub selection: SelectionOptions,
64
65 #[arg(long = "acyclic", conflicts_with = "focus_on")]
67 pub acyclic: bool,
68
69 #[arg(long = "layout", default_value = "neato")]
72 pub layout: LayoutAlgorithm,
73
74 #[arg(long = "focus-on")]
77 pub focus_on: Option<String>,
78
79 #[arg(long = "max-depth")]
82 pub max_depth: Option<usize>,
83
84 #[arg(long = "cfg-test")]
86 pub cfg_test: bool,
87}
88
89#[derive(Parser, Clone, PartialEq, Eq, Debug)]
96#[group(id = "SelectionOptions")]
97pub struct SelectionOptions {
98 #[arg(long = "no-externs")]
100 pub no_externs: bool,
101
102 #[arg(long = "no-fns")]
104 pub no_fns: bool,
105
106 #[clap(long = "no-modules")]
108 pub no_modules: bool,
109
110 #[clap(long = "no-owns")]
112 pub no_owns: bool,
113
114 #[arg(long = "no-sysroot")]
116 pub no_sysroot: bool,
117
118 #[arg(long = "no-traits")]
120 pub no_traits: bool,
121
122 #[arg(long = "no-types")]
124 pub no_types: bool,
125
126 #[arg(long = "no-uses")]
128 pub no_uses: bool,
129}