Skip to content

Commit

Permalink
Add container name argument
Browse files Browse the repository at this point in the history
  • Loading branch information
onur committed Jun 2, 2017
1 parent bedcc0c commit 87e4c85
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
16 changes: 14 additions & 2 deletions src/bin/cratesfyi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,19 @@ pub fn main() {
.takes_value(true))
.arg(Arg::with_name("CHROOT_PATH")
.short("c")
.long("chroot")
.long("chroot-path")
.help("Sets chroot path")
.takes_value(true))
.arg(Arg::with_name("CHROOT_USER")
.short("u")
.long("chroot-user")
.help("Sets chroot user name")
.takes_value(true))
.arg(Arg::with_name("CONTAINER_NAME")
.short("n")
.long("container-name")
.help("Sets name of the container")
.takes_value(true))
.arg(Arg::with_name("CRATES_IO_INDEX_PATH")
.long("crates-io-index-path")
.help("Sets crates.io-index path")
Expand Down Expand Up @@ -93,7 +98,8 @@ pub fn main() {
building new crates"))
.subcommand(SubCommand::with_name("unlock")
.about("Unlocks cratesfyi daemon to continue \
building new crates")))
building new crates"))
.subcommand(SubCommand::with_name("print-options")))
.subcommand(SubCommand::with_name("start-web-server")
.about("Starts web server")
.arg(Arg::with_name("SOCKET_ADDR")
Expand Down Expand Up @@ -158,6 +164,10 @@ pub fn main() {
docbuilder_opts.chroot_user = chroot_user.to_string();
}

if let Some(container_name) = matches.value_of("CONTAINER_NAME") {
docbuilder_opts.container_name = container_name.to_string();
}

if let Some(crates_io_index_path) = matches.value_of("CRATES_IO_INDEX_PATH") {
docbuilder_opts.crates_io_index_path = PathBuf::from(crates_io_index_path);
}
Expand Down Expand Up @@ -189,6 +199,8 @@ pub fn main() {
docbuilder.lock().expect("Failed to lock");
} else if let Some(_) = matches.subcommand_matches("unlock") {
docbuilder.unlock().expect("Failed to unlock");
} else if let Some(_) = matches.subcommand_matches("print-options") {
println!("{:?}", docbuilder.options());
}

} else if let Some(matches) = matches.subcommand_matches("database") {
Expand Down
5 changes: 5 additions & 0 deletions src/docbuilder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,9 @@ impl DocBuilder {
}
Ok(())
}

/// Returns a reference of options
pub fn options(&self) -> &DocBuilderOptions {
&self.options
}
}
3 changes: 2 additions & 1 deletion src/docbuilder/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,14 @@ impl fmt::Debug for DocBuilderOptions {
write!(f,
"DocBuilderOptions {{ destination: {:?}, chroot_path: {:?}, \
crates_io_index_path: {:?}, \
sources_path: {:?}, chroot_user: {:?}, \
sources_path: {:?}, container_name: {:?}, chroot_user: {:?}, \
keep_build_directory: {:?}, skip_if_exists: {:?}, \
skip_if_log_exists: {:?}, debug: {:?} }}",
self.destination,
self.chroot_path,
self.crates_io_index_path,
self.sources_path,
self.container_name,
self.chroot_user,
self.keep_build_directory,
self.skip_if_exists,
Expand Down

0 comments on commit 87e4c85

Please sign in to comment.