]>
git.proxmox.com Git - proxmox-backup.git/blob - src/bin/docgen.rs
1 use anyhow
::{bail, Error}
;
12 fn dump_section_config(config
: &SectionConfig
) -> String
{
14 let mut res
= String
::new();
16 let plugin_count
= config
.plugins().len();
18 for plugin
in config
.plugins().values() {
20 let name
= plugin
.type_name();
21 let properties
= plugin
.properties();
22 let skip
= match plugin
.id_property() {
28 res
.push_str(&format
!("\n**Section type** \'``{}``\'\n\n", name
));
31 res
.push_str(&dump_api_parameters(properties
, "", ParameterDisplayStyle
::Config
, &skip
));
37 fn get_args() -> (String
, Vec
<String
>) {
39 let mut args
= std
::env
::args();
40 let prefix
= args
.next().unwrap();
41 let prefix
= prefix
.rsplit('
/'
).next().unwrap().to_string(); // without path
42 let args
: Vec
<String
> = args
.collect();
47 fn main() -> Result
<(), Error
> {
49 let (_prefix
, args
) = get_args();
52 bail
!("missing arguments");
55 for arg
in args
.iter() {
57 "datastore.cfg" => println
!("{}", dump_section_config(&config
::datastore
::CONFIG
)),
58 "tape.cfg" => println
!("{}", dump_section_config(&config
::drive
::CONFIG
)),
59 "user.cfg" => println
!("{}", dump_section_config(&config
::user
::CONFIG
)),
60 "remote.cfg" => println
!("{}", dump_section_config(&config
::remote
::CONFIG
)),
61 "sync.cfg" => println
!("{}", dump_section_config(&config
::sync
::CONFIG
)),
62 "media-pool.cfg" => println
!("{}", dump_section_config(&config
::media_pool
::CONFIG
)),
63 _
=> bail
!("docgen: got unknown type"),