Skip to content

Commit d41a9c5

Browse files
p-shahiPrithvi Shahi
andauthored
refactor: enhance create log (#820)
* enhance create log * patch * dont print local network Co-authored-by: Prithvi Shahi <[email protected]>
1 parent 440f390 commit d41a9c5

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

src/dfx/src/commands/build.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult {
6565

6666
slog::info!(logger, "Building canisters...");
6767

68-
// TODO: remove the forcing of generating canister id once we have an update flow.
6968
canister_pool.build_or_fail(
7069
BuildConfig::from_config(&config)?
7170
.with_skip_frontend(args.is_present("skip-frontend"))

src/dfx/src/commands/canister/create.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::lib::error::{DfxError, DfxResult};
33
use crate::lib::message::UserMessage;
44
use crate::lib::models::canister_id_store::CanisterIdStore;
55
use crate::lib::progress_bar::ProgressBar;
6+
use crate::lib::provider::get_network_context;
67
use crate::lib::waiter::create_waiter;
78

89
use clap::{App, Arg, ArgMatches, SubCommand};
@@ -44,11 +45,20 @@ fn create_canister(env: &dyn Environment, canister_name: &str) -> DfxResult {
4445

4546
let mut canister_id_store = CanisterIdStore::for_env(env)?;
4647

48+
let network_name = get_network_context()?;
49+
50+
let non_default_network = if network_name == "local" {
51+
format!("")
52+
} else {
53+
format!("on network {:?} ", network_name)
54+
};
55+
4756
match canister_id_store.find(&canister_name) {
4857
Some(canister_id) => {
4958
let message = format!(
50-
"{:?} canister was already created and has canister id: {:?}",
59+
"{:?} canister was already created {}and has canister id: {:?}",
5160
canister_name,
61+
non_default_network,
5262
canister_id.to_text()
5363
);
5464
b.finish_with_message(&message);
@@ -58,8 +68,8 @@ fn create_canister(env: &dyn Environment, canister_name: &str) -> DfxResult {
5868
let cid = runtime.block_on(mgr.create_canister(create_waiter()))?;
5969
let canister_id = cid.to_text();
6070
let message = format!(
61-
"{:?} canister created with canister id: {:?}",
62-
canister_name, canister_id
71+
"{:?} canister created {}with canister id: {:?}",
72+
canister_name, non_default_network, canister_id
6373
);
6474
b.finish_with_message(&message);
6575
canister_id_store.add(&canister_name, canister_id)

0 commit comments

Comments
 (0)