Add build_subcommand! macro

This commit is contained in:
mario 2016-11-05 11:09:42 +01:00 committed by Matthias Beyer
parent a825f4aba6
commit 85cd326818

View file

@ -17,6 +17,15 @@ macro_rules! gen_types_buildui {
) )
} }
macro_rules! build_subcommand {
($name:expr, $module:ident) => (
$module::build_ui(Runtime::get_default_cli_builder(
$name,
&version!()[..],
$name))
)
}
gen_types_buildui!( gen_types_buildui!(
("../imag-bookmark/src/ui.rs", imagbookmark), ("../imag-bookmark/src/ui.rs", imagbookmark),
("../imag-counter/src/ui.rs", imagcounter), ("../imag-counter/src/ui.rs", imagcounter),
@ -28,66 +37,27 @@ gen_types_buildui!(
("../imag-tag/src/ui.rs", imagtag), ("../imag-tag/src/ui.rs", imagtag),
("../imag-todo/src/ui.rs", imagtodo), ("../imag-todo/src/ui.rs", imagtodo),
("../imag-view/src/ui.rs", imagview) ("../imag-view/src/ui.rs", imagview)
); );
fn main() { fn main() {
let mut app = Runtime::get_default_cli_builder( let mut app = Runtime::get_default_cli_builder(
"imag", "imag",
&version!()[..], &version!()[..],
"imag") "imag")
.subcommand( .subcommand(build_subcommand!("bookmark", imagbookmark))
imagbookmark::build_ui(Runtime::get_default_cli_builder( .subcommand(build_subcommand!("counter", imagcounter))
"bookmark", .subcommand(build_subcommand!("diary", imagdiary))
&version!()[..], .subcommand(build_subcommand!("link", imaglink))
"bookmark"))) .subcommand(build_subcommand!("notes", imagnotes))
.subcommand( .subcommand(build_subcommand!("ref", imagref))
imagcounter::build_ui(Runtime::get_default_cli_builder( .subcommand(build_subcommand!("store", imagstore))
"counter", .subcommand(build_subcommand!("tag", imagtag))
&version!()[..], .subcommand(build_subcommand!("todo", imagtodo))
"counter"))) .subcommand(build_subcommand!("view", imagview));
.subcommand(
imagdiary::build_ui(Runtime::get_default_cli_builder(
"diary",
&version!()[..],
"diary")))
.subcommand(
imaglink::build_ui(Runtime::get_default_cli_builder(
"link",
&version!()[..],
"link")))
.subcommand(
imagnotes::build_ui(Runtime::get_default_cli_builder(
"notes",
&version!()[..],
"notes")))
.subcommand(
imagref::build_ui(Runtime::get_default_cli_builder(
"ref",
&version!()[..],
"ref")))
.subcommand(
imagstore::build_ui(Runtime::get_default_cli_builder(
"store",
&version!()[..],
"store")))
.subcommand(
imagtag::build_ui(Runtime::get_default_cli_builder(
"tag",
&version!()[..],
"tag")))
.subcommand(
imagtodo::build_ui(Runtime::get_default_cli_builder(
"todo",
&version!()[..],
"todo")))
.subcommand(
imagview::build_ui(Runtime::get_default_cli_builder(
"view",
&version!()[..],
"view")))
;
app.gen_completions("imag", Shell::Bash, env!("OUT_DIR")); app.gen_completions("imag", Shell::Bash, env!("OUT_DIR"));
app.gen_completions("imag", Shell::Fish, env!("OUT_DIR")); app.gen_completions("imag", Shell::Fish, env!("OUT_DIR"));
app.gen_completions("imag", Shell::Zsh, env!("OUT_DIR")); app.gen_completions("imag", Shell::Zsh, env!("OUT_DIR"));
} }