Skip to content
Closed
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
81 changes: 67 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion e2e/bats/install.bash
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ teardown() {
@test "install fails if no argument is provided" {
assert_command_fail dfx canister install
assert_match "required arguments were not provided"
assert_match "--all"
assert_match "<canister_name>"
}
6 changes: 6 additions & 0 deletions nix/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
"url": "https://github.com/ztombol/bats-support/archive/24a72e14349690bcbf7c151b9d2d1cdd32d36eb1.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"clap": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can remove this

"ref": "master",
"repo": "ssh://git@github.com/dfinity-lab/clap",
"rev": "7788268d3768810e91a911da0916db0e15105cf0",
"type": "git"
},
"common": {
"ref": "master",
"repo": "ssh://git@github.com/dfinity-lab/common",
Expand Down
2 changes: 1 addition & 1 deletion src/dfx/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ actix-server = "0.6.1"
actix-web = "1.0.8"
atty = "0.2.13"
base64 = "0.11.0"
clap = "2.33.0"
clap = { git = "https://github.com/clap-rs/clap", rev = "7788268d3768810e91a911da0916db0e15105cf0" }
console = "0.7.7"
crossbeam = "0.7.3"
delay = "0.1.0"
Expand Down
23 changes: 10 additions & 13 deletions src/dfx/src/commands/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::lib::environment::Environment;
use crate::lib::error::{DfxError, DfxResult};
use crate::lib::message::UserMessage;
use crate::lib::webserver::webserver;
use clap::{App, Arg, ArgMatches, SubCommand};
use clap::{App, Arg, ArgMatches};
use slog::info;
use std::default::Default;
use std::fs;
Expand All @@ -14,8 +14,8 @@ use std::str::FromStr;
use url::{ParseError, Url};

/// Constructs a sub-command to run the bootstrap server.
pub fn construct() -> App<'static, 'static> {
SubCommand::with_name("bootstrap")
pub fn construct() -> App<'static> {
App::new("bootstrap")
.about(UserMessage::BootstrapCommand.to_str())
.arg(
Arg::with_name("ip")
Expand Down Expand Up @@ -51,7 +51,7 @@ pub fn construct() -> App<'static, 'static> {
}

/// Runs the bootstrap server.
pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult {
pub fn exec(env: &dyn Environment, args: &ArgMatches) -> DfxResult {
let logger = env.get_logger();
let config = get_config(env, args)?;

Expand Down Expand Up @@ -88,7 +88,7 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult {

/// Gets the configuration options for the bootstrap server. Each option is checked for correctness
/// and otherwise guaranteed to exist.
fn get_config(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult<ConfigDefaultsBootstrap> {
fn get_config(env: &dyn Environment, args: &ArgMatches) -> DfxResult<ConfigDefaultsBootstrap> {
let config = get_config_from_file(env);
let ip = get_ip(&config, args)?;
let port = get_port(&config, args)?;
Expand Down Expand Up @@ -119,7 +119,7 @@ fn get_config_from_file(env: &dyn Environment) -> ConfigDefaultsBootstrap {
/// Gets the IP address that the bootstrap server listens on. First checks if the IP address was
/// specified on the command-line using --ip, otherwise checks if the IP address was specified in
/// the dfx configuration file, otherise defaults to 127.0.0.1.
fn get_ip(config: &ConfigDefaultsBootstrap, args: &ArgMatches<'_>) -> DfxResult<IpAddr> {
fn get_ip(config: &ConfigDefaultsBootstrap, args: &ArgMatches) -> DfxResult<IpAddr> {
args.value_of("ip")
.map(|ip| ip.parse())
.unwrap_or_else(|| {
Expand All @@ -132,7 +132,7 @@ fn get_ip(config: &ConfigDefaultsBootstrap, args: &ArgMatches<'_>) -> DfxResult<
/// Gets the port number that the bootstrap server listens on. First checks if the port number was
/// specified on the command-line using --port, otherwise checks if the port number was specified
/// in the dfx configuration file, otherise defaults to 8081.
fn get_port(config: &ConfigDefaultsBootstrap, args: &ArgMatches<'_>) -> DfxResult<u16> {
fn get_port(config: &ConfigDefaultsBootstrap, args: &ArgMatches) -> DfxResult<u16> {
args.value_of("port")
.map(|port| port.parse())
.unwrap_or_else(|| {
Expand All @@ -145,10 +145,7 @@ fn get_port(config: &ConfigDefaultsBootstrap, args: &ArgMatches<'_>) -> DfxResul
/// Gets the list of compute provider API endpoints. First checks if the providers were specified
/// on the command-line using --providers, otherwise checks if the providers were specified in the
/// dfx configuration file, otherwise defaults to http://127.0.0.1:8080/api.
fn get_providers(
config: &ConfigDefaultsBootstrap,
args: &ArgMatches<'_>,
) -> DfxResult<Vec<String>> {
fn get_providers(config: &ConfigDefaultsBootstrap, args: &ArgMatches) -> DfxResult<Vec<String>> {
args.values_of("providers")
.map(|providers| {
providers
Expand Down Expand Up @@ -178,7 +175,7 @@ fn get_providers(
fn get_root(
config: &ConfigDefaultsBootstrap,
env: &dyn Environment,
args: &ArgMatches<'_>,
args: &ArgMatches,
) -> DfxResult<PathBuf> {
args.value_of("root")
.map(|root| parse_dir(root))
Expand All @@ -205,7 +202,7 @@ fn get_root(
/// requests to complete. First checks if the timeout was specified on the command-line using
/// --timeout, otherwise checks if the timeout was specified in the dfx configuration file,
/// otherise defaults to 30.
fn get_timeout(config: &ConfigDefaultsBootstrap, args: &ArgMatches<'_>) -> DfxResult<u64> {
fn get_timeout(config: &ConfigDefaultsBootstrap, args: &ArgMatches) -> DfxResult<u64> {
args.value_of("timeout")
.map(|timeout| timeout.parse())
.unwrap_or_else(|| {
Expand Down
8 changes: 4 additions & 4 deletions src/dfx/src/commands/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ use crate::lib::environment::Environment;
use crate::lib::error::{BuildErrorKind, DfxError, DfxResult};
use crate::lib::message::UserMessage;
use crate::lib::models::canister::CanisterPool;
use clap::{App, Arg, ArgMatches, SubCommand};
use clap::{App, Arg, ArgMatches};

pub fn construct() -> App<'static, 'static> {
SubCommand::with_name("build")
pub fn construct() -> App<'static> {
App::new("build")
.about(UserMessage::BuildCanister.to_str())
.arg(
Arg::with_name("skip-frontend")
Expand All @@ -17,7 +17,7 @@ pub fn construct() -> App<'static, 'static> {
)
}

pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult {
pub fn exec(env: &dyn Environment, args: &ArgMatches) -> DfxResult {
let logger = env.get_logger();

// Read the config.
Expand Down
8 changes: 4 additions & 4 deletions src/dfx/src/commands/cache/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ use crate::config::cache::delete_version;
use crate::lib::environment::Environment;
use crate::lib::error::DfxResult;
use crate::lib::message::UserMessage;
use clap::{App, Arg, ArgMatches, SubCommand};
use clap::{App, Arg, ArgMatches};

pub fn construct() -> App<'static, 'static> {
SubCommand::with_name("delete")
pub fn construct() -> App<'static> {
App::new("delete")
.about(UserMessage::CacheDelete.to_str())
.arg(Arg::with_name("version").takes_value(true))
}

pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult {
pub fn exec(env: &dyn Environment, args: &ArgMatches) -> DfxResult {
match args.value_of("version") {
Some(v) => delete_version(v).map(|_| {}),
_ => env.get_cache().delete(),
Expand Down
8 changes: 4 additions & 4 deletions src/dfx/src/commands/cache/install.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use crate::lib::environment::Environment;
use crate::lib::error::DfxResult;
use crate::lib::message::UserMessage;
use clap::{App, ArgMatches, SubCommand};
use clap::{App, ArgMatches};

pub fn construct() -> App<'static, 'static> {
SubCommand::with_name("install").about(UserMessage::CacheUnpack.to_str())
pub fn construct() -> App<'static> {
App::new("install").about(UserMessage::CacheUnpack.to_str())
}

pub fn exec(env: &dyn Environment, _args: &ArgMatches<'_>) -> DfxResult {
pub fn exec(env: &dyn Environment, _args: &ArgMatches) -> DfxResult {
env.get_cache().force_install()
}
8 changes: 4 additions & 4 deletions src/dfx/src/commands/cache/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ use crate::config::{cache, dfx_version};
use crate::lib::environment::Environment;
use crate::lib::error::DfxResult;
use crate::lib::message::UserMessage;
use clap::{App, ArgMatches, SubCommand};
use clap::{App, ArgMatches};
use std::io::Write;

pub fn construct() -> App<'static, 'static> {
SubCommand::with_name("list").about(UserMessage::CacheList.to_str())
pub fn construct() -> App<'static> {
App::new("list").about(UserMessage::CacheList.to_str())
}

pub fn exec(env: &dyn Environment, _args: &ArgMatches<'_>) -> DfxResult {
pub fn exec(env: &dyn Environment, _args: &ArgMatches) -> DfxResult {
let mut current_printed = false;
let current_version = env.get_version();
let mut all_versions = cache::list_versions()?;
Expand Down
Loading