[−][src]Module dia_args::docs
Kit for documentation
Examples
use dia_args::docs::{self, Cfg, Cmd, Docs, I18n, Opt}; const CMD_HELP: &str = "help"; const CMD_HELP_DOCS: &str = "Prints help and exits."; const CMD_VERSION: &str = "version"; const CMD_VERSION_DOCS: &str = "Prints version and exits."; const CMD_DO_SOMETHING: &str = "do-something"; const CMD_DO_SOMETHING_DOCS: &str = concat!( "This command does something.\n", "\n", "It might NOT do that thing. If you encounter any problems,", " please contact developers.\n", ); const ARG_THIS: &[&str] = &["-t", "--this"]; const ARG_THIS_DEFAULT: bool = true; const ARG_THIS_DOCS: &str = "This argument has 2 names."; const ARG_THAT: &[&str] = &["--that"]; const ARG_THAT_VALUES: &[u8] = &[99, 100]; const ARG_THAT_DEFAULT: u8 = ARG_THAT_VALUES[0]; const ARG_THAT_DOCS: &str = "This argument has 1 single name."; let help_cmd = Cmd::new(CMD_HELP, CMD_HELP_DOCS.into(), None); let version_cmd = Cmd::new(CMD_VERSION, CMD_VERSION_DOCS.into(), None); let do_something_cmd = Cmd::new( CMD_DO_SOMETHING, CMD_DO_SOMETHING_DOCS.into(), Some(dia_args::make_opts![ Opt::new( ARG_THIS, false, None, Some(&ARG_THIS_DEFAULT), ARG_THIS_DOCS.into(), ), Opt::new( ARG_THAT, true, Some(docs::make_cow_strings(ARG_THAT_VALUES)), Some(&ARG_THAT_DEFAULT), ARG_THAT_DOCS.into(), ), ]), ); let docs = Docs::new( // Name "The-Program".into(), // Docs "This is the Program".into(), // Configuration Cfg::default(), // Internatinonalization I18n::default(), // Program options None, // Commands Some(dia_args::make_cmds![help_cmd, version_cmd, do_something_cmd,]), ); docs.print(); // This does the same as above command: // println!("{}", docs);
Structs
Cfg | Configuration |
Cmd | Command |
Docs | Documentation |
I18n | Internatinonalization |
Opt | Option |
Functions
make_cow_strings | Makes a vector of |