]> git.proxmox.com Git - proxmox-backup.git/blame - src/bin/docgen.rs
tape: extend MediaChange trait to return MtxStatus
[proxmox-backup.git] / src / bin / docgen.rs
CommitLineData
2322a980
DM
1use anyhow::{bail, Error};
2
2ca396c0
DM
3use proxmox::api::format::{
4 dump_enum_properties,
5 dump_section_config,
6};
2322a980
DM
7
8use proxmox_backup::{
9 config,
10};
11
2322a980
DM
12fn get_args() -> (String, Vec<String>) {
13
14 let mut args = std::env::args();
15 let prefix = args.next().unwrap();
16 let prefix = prefix.rsplit('/').next().unwrap().to_string(); // without path
17 let args: Vec<String> = args.collect();
18
19 (prefix, args)
20}
21
22fn main() -> Result<(), Error> {
23
24 let (_prefix, args) = get_args();
25
26 if args.len() < 1 {
27 bail!("missing arguments");
28 }
29
30 for arg in args.iter() {
2ca396c0
DM
31 let text = match arg.as_ref() {
32 "datastore.cfg" => dump_section_config(&config::datastore::CONFIG),
33 "tape.cfg" => dump_section_config(&config::drive::CONFIG),
7ca0ba45 34 "tape-job.cfg" => dump_section_config(&config::tape_job::CONFIG),
2ca396c0
DM
35 "user.cfg" => dump_section_config(&config::user::CONFIG),
36 "remote.cfg" => dump_section_config(&config::remote::CONFIG),
37 "sync.cfg" => dump_section_config(&config::sync::CONFIG),
5b7f4455 38 "verification.cfg" => dump_section_config(&config::verify::CONFIG),
2ca396c0
DM
39 "media-pool.cfg" => dump_section_config(&config::media_pool::CONFIG),
40 "config::acl::Role" => dump_enum_properties(&config::acl::Role::API_SCHEMA)?,
2322a980 41 _ => bail!("docgen: got unknown type"),
2ca396c0
DM
42 };
43 println!("{}", text);
2322a980
DM
44 }
45
46 Ok(())
47}