1pub mod backup;
2pub mod build;
3pub mod config;
4pub mod deploy;
5pub mod doctor;
6pub mod export;
7pub mod import;
8pub mod import_ghost;
9pub mod import_wordpress;
10pub mod init;
11pub mod migrate;
12pub mod registry;
13pub mod rerender;
14pub mod serve;
15pub mod user;
16
17use clap::{Parser, Subcommand};
18use std::path::PathBuf;
19
20#[derive(Parser)]
21#[command(name = "pebble")]
22#[command(version)]
23#[command(about = "A lightweight personal CMS", long_about = None)]
24pub struct Cli {
25 #[arg(short, long, default_value = "pebble.toml")]
26 pub config: PathBuf,
27
28 #[command(subcommand)]
29 pub command: Option<Commands>,
30}
31
32#[derive(Subcommand)]
33pub enum Commands {
34 Init {
36 #[arg(default_value = ".")]
38 path: PathBuf,
39 #[arg(long)]
41 name: Option<String>,
42 },
43 Serve {
45 #[arg(short = 'H', long, default_value = "127.0.0.1")]
47 host: String,
48 #[arg(short, long, default_value = "3000")]
50 port: u16,
51 },
52 Deploy {
54 #[arg(short = 'H', long, default_value = "0.0.0.0")]
56 host: String,
57 #[arg(short, long, default_value = "8080")]
59 port: u16,
60 },
61 Build {
63 #[arg(short, long, default_value = "./dist")]
65 output: PathBuf,
66 #[arg(long)]
68 base_url: Option<String>,
69 },
70 Export {
72 #[arg(short, long, default_value = "./export")]
74 output: PathBuf,
75 #[arg(long)]
77 include_drafts: bool,
78 #[arg(long)]
80 include_media: bool,
81 #[arg(long, default_value = "pebble")]
83 format: String,
84 },
85 Import {
87 #[arg(default_value = "./export")]
89 path: PathBuf,
90 #[arg(long)]
92 overwrite: bool,
93 },
94 ImportWp {
96 file: PathBuf,
98 #[arg(long)]
100 overwrite: bool,
101 },
102 ImportGhost {
104 file: PathBuf,
106 #[arg(long)]
108 overwrite: bool,
109 },
110 Backup {
112 #[command(subcommand)]
113 command: BackupCommand,
114 },
115 Migrate {
117 #[command(subcommand)]
118 command: Option<MigrateCommand>,
119 },
120 Doctor,
122 Rerender,
124 User {
126 #[command(subcommand)]
127 command: UserCommand,
128 },
129 Config {
131 #[command(subcommand)]
132 command: ConfigCommand,
133 },
134 Registry {
136 #[command(subcommand)]
137 command: RegistryCommand,
138 },
139}
140
141#[derive(Subcommand)]
142pub enum UserCommand {
143 Add {
144 #[arg(long)]
145 username: String,
146 #[arg(long)]
147 email: String,
148 #[arg(long, default_value = "author")]
149 role: String,
150 #[arg(long)]
151 password: Option<String>,
152 },
153 List,
154 Remove {
155 username: String,
156 },
157 Passwd {
158 username: String,
159 },
160}
161
162#[derive(Subcommand)]
163pub enum BackupCommand {
164 Create {
165 #[arg(short, long, default_value = "./backups")]
166 output: PathBuf,
167 },
168 Restore {
169 file: PathBuf,
170 },
171 List {
172 #[arg(short, long, default_value = "./backups")]
173 dir: PathBuf,
174 },
175}
176
177#[derive(Subcommand)]
178pub enum MigrateCommand {
179 Status,
181 Rollback {
183 #[arg(short, long, default_value = "1")]
185 steps: u32,
186 #[arg(long)]
188 force: bool,
189 },
190}
191
192#[derive(Subcommand)]
193pub enum ConfigCommand {
194 Get { key: String },
195 Set { key: String, value: String },
196 List,
197 Remove { key: String },
198 Path,
199}
200
201#[derive(Subcommand)]
202pub enum RegistryCommand {
203 Init {
205 name: String,
207 #[arg(long)]
209 title: Option<String>,
210 },
211 List,
213 Serve {
215 name: String,
217 #[arg(short, long)]
219 port: Option<u16>,
220 },
221 Deploy {
223 name: String,
225 #[arg(short, long)]
227 port: Option<u16>,
228 },
229 Stop {
231 name: String,
233 },
234 StopAll,
236 Remove {
238 name: String,
240 #[arg(long)]
242 force: bool,
243 },
244 Status {
246 name: String,
248 },
249 Path {
251 name: Option<String>,
253 },
254 Rerender {
256 name: String,
258 },
259 Config {
261 name: String,
263 #[command(subcommand)]
264 command: Option<SiteConfigCommand>,
265 },
266}
267
268#[derive(Subcommand)]
269pub enum SiteConfigCommand {
270 Get {
272 key: String,
274 },
275 Set {
277 key: String,
279 value: String,
281 },
282 Edit,
284}