Skip to content

Commit 587671f

Browse files
committed
feat: update colors and messages
1 parent 9e7b7ba commit 587671f

File tree

4 files changed

+29
-20
lines changed

4 files changed

+29
-20
lines changed

src/frontend/cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ fn execute_changes(changes: Vec<Changes>) {
447447
Changes::AddFile(options) => {
448448
if let Ok(entry) = fs::metadata(&options.path) {
449449
if entry.is_file() {
450-
println!("File already exists at path {}", options.path);
450+
println!("{}, file already exists at path {}", red!("Skip creating file"), options.path);
451451
continue;
452452
}
453453
}

src/generate/contract.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl GetChangesForNewContract {
6161
};
6262
let path = format!("{}/contracts/{}", project_path.to_string_lossy(), name);
6363
let change = FileCreation {
64-
comment: format!("Creating file contracts/{}", name),
64+
comment: format!("{} contracts/{}", green!("Created file"), name),
6565
name,
6666
content,
6767
path,
@@ -107,7 +107,7 @@ Clarinet.test({{
107107
let name = format!("{}_test.ts", self.contract_name);
108108
let path = format!("{}/tests/{}", project_path.to_string_lossy(), name);
109109
let change = FileCreation {
110-
comment: format!("Creating file tests/{}", name),
110+
comment: format!("{} tests/{}", green!("Created file"), name),
111111
name,
112112
content,
113113
path,
@@ -127,7 +127,7 @@ Clarinet.test({{
127127
contracts_to_add.insert(self.contract_name.clone(), contract_config);
128128

129129
let change = TOMLEdition {
130-
comment: format!("Adding contract {} to Clarinet.toml", self.contract_name),
130+
comment: format!("{} with contract {}", yellow!("Updated Clarinet.toml"), self.contract_name),
131131
manifest_path,
132132
contracts_to_add,
133133
requirements_to_add: vec![],

src/generate/project.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl GetChangesForNewProject {
3232
fn create_root_directory(&mut self) {
3333
let dir = format!("{}/{}", self.project_path, self.project_name);
3434
let change = DirectoryCreation {
35-
comment: format!("Creating directory {}", self.project_name),
35+
comment: format!("{} {}", green!("Creating directory"), self.project_name),
3636
name: self.project_name.clone(),
3737
path: dir,
3838
};
@@ -88,7 +88,7 @@ impl GetChangesForNewProject {
8888
self.project_path, self.project_name, name
8989
);
9090
let change = FileCreation {
91-
comment: format!("Creating file {}/.vscode/{}", self.project_name, name),
91+
comment: format!("{} {}/.vscode/{}", green!("Created file"), self.project_name, name),
9292
name,
9393
content,
9494
path,
@@ -107,7 +107,7 @@ history.txt
107107
let name = format!(".gitignore");
108108
let path = format!("{}/{}/{}", self.project_path, self.project_name, name);
109109
let change = FileCreation {
110-
comment: format!("Creating file {}/{}", self.project_name, name),
110+
comment: format!("{} {}/{}", green!("Created file"), self.project_name, name),
111111
name,
112112
content,
113113
path,
@@ -130,7 +130,7 @@ name = "{}"
130130
let name = format!("Clarinet.toml");
131131
let path = format!("{}/{}/{}", self.project_path, self.project_name, name);
132132
let change = FileCreation {
133-
comment: format!("Creating file {}/{}", self.project_name, name),
133+
comment: format!("{} {}/{}", green!("Created file"), self.project_name, name),
134134
name,
135135
content,
136136
path,
@@ -155,7 +155,7 @@ mnemonic = "<YOUR PRIVATE TESTNET MNEMONIC HERE>"
155155
self.project_path, self.project_name, name
156156
);
157157
let change = FileCreation {
158-
comment: format!("Creating file {}/settings/{}", self.project_name, name),
158+
comment: format!("{} {}/settings/{}", green!("Created file"), self.project_name, name),
159159
name,
160160
content,
161161
path,
@@ -180,7 +180,7 @@ mnemonic = "<YOUR PRIVATE MAINNET MNEMONIC HERE>"
180180
self.project_path, self.project_name, name
181181
);
182182
let change = FileCreation {
183-
comment: format!("Creating file {}/settings/{}", self.project_name, name),
183+
comment: format!("{} {}/settings/{}", green!("Created file"), self.project_name, name),
184184
name,
185185
content,
186186
path,
@@ -324,7 +324,7 @@ btc_address = "mvZtbibDAAA3WLpY7zXXFqRa3T4XSknBX7"
324324
self.project_path, self.project_name, name
325325
);
326326
let change = FileCreation {
327-
comment: format!("Creating file {}/settings/{}", self.project_name, name),
327+
comment: format!("{} {}/settings/{}", green!("Created file"), self.project_name, name),
328328
name,
329329
content,
330330
path,
@@ -335,7 +335,7 @@ btc_address = "mvZtbibDAAA3WLpY7zXXFqRa3T4XSknBX7"
335335
fn get_changes_for_new_root_dir(&self, name: String) -> Changes {
336336
let dir = format!("{}/{}", self.project_name, name);
337337
let change = DirectoryCreation {
338-
comment: format!("Creating directory {}/{}", self.project_name, name),
338+
comment: format!("{} {}/{}", green!("Created file"), self.project_name, name),
339339
name,
340340
path: dir,
341341
};

src/macros.rs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ macro_rules! green {
55
use atty::Stream;
66
use ansi_term::Colour;
77
if atty::is(Stream::Stdout) {
8-
let colour = Colour::Green;
8+
let colour = Colour::Green.bold();
99
format!(
1010
"{}",
1111
colour.paint($($arg)*)
@@ -24,11 +24,20 @@ macro_rules! green {
2424
macro_rules! red {
2525
($($arg:tt)*) => (
2626
{
27-
use std::io::Write;
28-
use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor};
29-
let mut stdout = StandardStream::stdout(ColorChoice::Always);
30-
stdout.set_color(ColorSpec::new().set_fg(Some(Color::Red)));
31-
writeln!(&mut stdout, $($arg)*)
27+
use atty::Stream;
28+
use ansi_term::Colour;
29+
if atty::is(Stream::Stdout) {
30+
let colour = Colour::Red.bold();
31+
format!(
32+
"{}",
33+
colour.paint($($arg)*)
34+
)
35+
} else {
36+
format!(
37+
"{}",
38+
$($arg)*
39+
)
40+
}
3241
}
3342
)
3443
}
@@ -40,7 +49,7 @@ macro_rules! yellow {
4049
use atty::Stream;
4150
use ansi_term::Colour;
4251
if atty::is(Stream::Stdout) {
43-
let colour = Colour::Yellow;
52+
let colour = Colour::Yellow.bold();
4453
format!(
4554
"{}",
4655
colour.paint($($arg)*)
@@ -62,7 +71,7 @@ macro_rules! blue {
6271
use atty::Stream;
6372
use ansi_term::Colour;
6473
if atty::is(Stream::Stdout) {
65-
let colour = Colour::Cyan;
74+
let colour = Colour::Cyan.bold();
6675
format!(
6776
"{}",
6877
colour.paint($($arg)*)

0 commit comments

Comments
 (0)