Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use dep syntax with getopts #591

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions timely/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ license = "MIT"

[features]
default = ["getopts"]
getopts = ["getopts-dep", "timely_communication/getopts"]
getopts = ["dep:getopts", "timely_communication/getopts"]

[dependencies]
getopts-dep = { package = "getopts", version = "0.2.14", optional = true }
getopts = { version = "0.2.14", optional = true }
bincode = { version = "1.0" }
serde = { version = "1.0", features = ["derive"] }
timely_bytes = { path = "../bytes", version = "0.12" }
Expand Down
10 changes: 5 additions & 5 deletions timely/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub struct Config {
}

impl Config {
/// Installs options into a [getopts_dep::Options] struct that correspond
/// Installs options into a [getopts::Options] struct that correspond
/// to the parameters in the configuration.
///
/// It is the caller's responsibility to ensure that the installed options
Expand All @@ -25,21 +25,21 @@ impl Config {
/// This method is only available if the `getopts` feature is enabled, which
/// it is by default.
#[cfg(feature = "getopts")]
pub fn install_options(opts: &mut getopts_dep::Options) {
pub fn install_options(opts: &mut getopts::Options) {
CommunicationConfig::install_options(opts);
WorkerConfig::install_options(opts);
}

/// Instantiates a configuration based upon the parsed options in `matches`.
///
/// The `matches` object must have been constructed from a
/// [getopts_dep::Options] which contained at least the options installed by
/// [getopts::Options] which contained at least the options installed by
/// [Self::install_options].
///
/// This method is only available if the `getopts` feature is enabled, which
/// it is by default.
#[cfg(feature = "getopts")]
pub fn from_matches(matches: &getopts_dep::Matches) -> Result<Config, String> {
pub fn from_matches(matches: &getopts::Matches) -> Result<Config, String> {
Ok(Config {
communication: CommunicationConfig::from_matches(matches)?,
worker: WorkerConfig::from_matches(matches)?,
Expand All @@ -51,7 +51,7 @@ impl Config {
/// Most commonly, callers supply `std::env::args()` as the iterator.
#[cfg(feature = "getopts")]
pub fn from_args<I: Iterator<Item=String>>(args: I) -> Result<Config, String> {
let mut opts = getopts_dep::Options::new();
let mut opts = getopts::Options::new();
Config::install_options(&mut opts);
let matches = opts.parse(args).map_err(|e| e.to_string())?;
Config::from_matches(&matches)
Expand Down
8 changes: 4 additions & 4 deletions timely/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ pub struct Config {
}

impl Config {
/// Installs options into a [getopts_dep::Options] struct that correspond
/// Installs options into a [getopts::Options] struct that correspond
/// to the parameters in the configuration.
///
/// It is the caller's responsibility to ensure that the installed options
Expand All @@ -102,20 +102,20 @@ impl Config {
/// This method is only available if the `getopts` feature is enabled, which
/// it is by default.
#[cfg(feature = "getopts")]
pub fn install_options(opts: &mut getopts_dep::Options) {
pub fn install_options(opts: &mut getopts::Options) {
opts.optopt("", "progress-mode", "progress tracking mode (eager or demand)", "MODE");
}

/// Instantiates a configuration based upon the parsed options in `matches`.
///
/// The `matches` object must have been constructed from a
/// [getopts_dep::Options] which contained at least the options installed by
/// [getopts::Options] which contained at least the options installed by
/// [Self::install_options].
///
/// This method is only available if the `getopts` feature is enabled, which
/// it is by default.
#[cfg(feature = "getopts")]
pub fn from_matches(matches: &getopts_dep::Matches) -> Result<Config, String> {
pub fn from_matches(matches: &getopts::Matches) -> Result<Config, String> {
let progress_mode = matches
.opt_get_default("progress-mode", ProgressMode::Eager)?;
Ok(Config::default().progress_mode(progress_mode))
Expand Down