Skip to content

Commit cb89b06

Browse files
committed
Require at least one input of the assembly or module type
1 parent 5c5a9dc commit cb89b06

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/main.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ use std::path::PathBuf;
44

55
extern crate clap;
66
use clap::{
7-
crate_authors, crate_description, crate_name, crate_version, App, AppSettings, Arg, Values,
7+
crate_authors, crate_description, crate_name, crate_version, App, AppSettings, Arg, ArgGroup,
8+
Values,
89
};
910

1011
extern crate colored;
@@ -122,6 +123,13 @@ fn main() {
122123
.multiple(true)
123124
.help("Create a reference module"),
124125
)
126+
// This group ensures that at least one of the assembly or module inputs is present
127+
.group(
128+
ArgGroup::with_name("modules")
129+
.args(&["assembly", "concept", "procedure", "reference"])
130+
.required(true)
131+
.multiple(true),
132+
)
125133
.arg(
126134
Arg::with_name("no-comments")
127135
.short("C")
@@ -339,6 +347,7 @@ impl Module {
339347
}
340348

341349
if let Some(includes) = includes {
350+
// The includes should never be empty thanks to the required group in clap
342351
assert!(!includes.is_empty());
343352
// Join the includes into a block of text, with blank lines in between to prevent
344353
// the AsciiDoc syntax to blend between modules

0 commit comments

Comments
 (0)