1use crate::targets::Target;
5use crate::vault::SecretFormat;
6use clap::{Args, Parser, Subcommand};
7
8#[derive(Debug, Clone, Copy)]
9pub struct CliFlags {
11 pub json: bool,
12 pub non_interactive: bool,
13 pub dry_run: bool,
14 pub yes: bool,
15 pub no_color: bool,
16}
17
18#[derive(Parser)]
19#[command(name = "cred")]
20#[command(about = "Local-first credential manager", long_about = None)]
21pub struct Cli {
22 #[arg(long, global = true)]
24 pub json: bool,
25 #[arg(long, global = true)]
27 pub non_interactive: bool,
28 #[arg(long, global = true)]
30 pub dry_run: bool,
31 #[arg(long, short = 'y', global = true)]
33 pub yes: bool,
34
35 #[command(subcommand)]
36 pub command: Commands,
37}
38
39#[derive(Subcommand)]
40pub enum Commands {
41 Init,
43
44 Doctor,
46
47 Target {
49 #[command(subcommand)]
50 action: TargetAction,
51 },
52
53 Secret {
55 #[command(subcommand)]
56 action: SecretAction,
57 },
58
59 Import(ImportArgs),
61
62 Export(ExportArgs),
64
65 Push(PushArgs),
67
68 Prune(PruneArgs),
70
71 Config {
73 #[command(subcommand)]
74 action: ConfigAction,
75 },
76
77 Project {
79 #[command(subcommand)]
80 action: ProjectAction,
81 },
82}
83
84#[derive(Args, Debug)]
85pub struct PushArgs {
86 pub target: Target,
88
89 #[arg(num_args = 0..)]
91 pub keys: Vec<String>,
92
93 #[arg(long)]
95 pub repo: Option<String>,
96}
97
98#[derive(Args, Debug)]
99pub struct PruneArgs {
100 pub target: Target,
102
103 #[arg(num_args = 0..)]
105 pub keys: Vec<String>,
106
107 #[arg(long)]
109 pub repo: Option<String>,
110
111 #[arg(long)]
113 pub all: bool,
114}
115
116#[derive(Subcommand, Debug)]
117pub enum ConfigAction {
118 Get { key: String },
120 Set { key: String, value: String },
122 Unset { key: String },
124 List,
126}
127
128#[derive(Subcommand, Debug)]
129pub enum ProjectAction {
130 Status,
132}
133
134#[derive(Subcommand, Debug)]
135pub enum TargetAction {
136 Set(SetTargetArgs),
137 List,
138 Revoke {
140 name: Target,
141 },
142}
143
144#[derive(Args, Debug)]
145pub struct SetTargetArgs {
146 pub name: Target,
147
148 #[arg(long)]
150 pub token: Option<String>,
151}
152
153#[derive(Subcommand, Debug)]
154pub enum SecretAction {
155 Set {
157 key: String,
158 value: String,
159 #[arg(long, short = 'd')]
161 description: Option<String>,
162 #[arg(long, short = 'f')]
164 format: Option<SecretFormat>,
165 },
166 Get { key: String },
168 List {},
170 Describe {
172 key: String,
173 description: Option<String>,
175 },
176 Remove { key: String },
178 Revoke {
180 key: String,
181 #[arg(long)]
182 target: Target,
183 },
184}
185
186#[derive(Args, Debug)]
187pub struct ImportArgs {
188 pub path: String,
190 #[arg(long)]
192 pub overwrite: bool,
193}
194
195#[derive(Args, Debug)]
196pub struct ExportArgs {
197 pub path: String,
199 #[arg(long)]
201 pub force: bool,
202}