@@ -25,15 +25,9 @@ fn main() {
25
25
. expect ( "Error setting Ctrl-C handler" ) ;
26
26
}
27
27
28
- if let Err ( e) = cliclack:: clear_screen ( ) {
29
- eprintln ! ( "Error clearing screen: {}" , e) ;
30
- exit ( 1 ) ;
31
- }
28
+ cliclack:: clear_screen ( ) . unwrap ( ) ;
32
29
33
- if let Err ( e) = cliclack:: intro ( "CM-IV CLI" . on_cyan ( ) . black ( ) ) {
34
- eprintln ! ( "Error showing intro: {}" , e) ;
35
- exit ( 1 ) ;
36
- }
30
+ cliclack:: intro ( "CM-IV CLI" . on_cyan ( ) . black ( ) ) . unwrap ( ) ;
37
31
38
32
let path = match cliclack:: input ( "Where should we create your project?" )
39
33
. placeholder ( "./sparkling-solid" )
@@ -49,12 +43,12 @@ fn main() {
49
43
. interact ( )
50
44
{
51
45
Ok ( path) => path,
52
- Err ( e ) => {
46
+ Err ( _ ) => {
53
47
if should_terminate. load ( Ordering :: SeqCst ) {
54
- println ! ( "\n Gracefully exiting..." ) ;
48
+ cliclack :: log :: remark ( "\n Gracefully exiting..." ) . unwrap ( ) ;
55
49
exit ( 0 ) ;
56
50
} else {
57
- eprintln ! ( "Error with input: {}" , e ) ;
51
+ cliclack :: log :: error ( " \n Error with input, exiting..." ) . unwrap ( ) ;
58
52
exit ( 1 ) ;
59
53
}
60
54
}
@@ -73,12 +67,12 @@ fn main() {
73
67
. interact ( )
74
68
{
75
69
Ok ( kind) => kind,
76
- Err ( e ) => {
70
+ Err ( _ ) => {
77
71
if should_terminate. load ( Ordering :: SeqCst ) {
78
- println ! ( "Gracefully exiting...") ;
72
+ cliclack :: log :: remark ( " \n Gracefully exiting...") . unwrap ( ) ;
79
73
exit ( 0 ) ;
80
74
} else {
81
- eprintln ! ( "Error with selection: {}" , e ) ;
75
+ cliclack :: log :: error ( " \n Error with selection, exiting..." ) . unwrap ( ) ;
82
76
exit ( 1 ) ;
83
77
}
84
78
}
@@ -98,14 +92,6 @@ fn copy_template(install_path: String, kind: &str, dirs: &[DirEntry]) {
98
92
99
93
let extracted_template_path = d. path ( ) . join ( kind) ;
100
94
101
- if !extracted_template_path. exists ( ) {
102
- eprintln ! (
103
- "Template path does not exist: {}" ,
104
- extracted_template_path. display( )
105
- ) ;
106
- continue ;
107
- }
108
-
109
95
let target_path = std:: path:: Path :: new ( & format ! (
110
96
"{}/{}" ,
111
97
std:: env:: current_dir( ) . unwrap( ) . display( ) ,
@@ -119,23 +105,16 @@ fn copy_template(install_path: String, kind: &str, dirs: &[DirEntry]) {
119
105
}
120
106
121
107
let mut entries: Vec < PathBuf > = vec ! [ ] ;
108
+
122
109
if let Ok ( dir_entries) = std:: fs:: read_dir ( & extracted_template_path) {
123
110
for entry in dir_entries {
124
111
if let Ok ( entry) = entry {
125
112
entries. push ( entry. path ( ) ) ;
126
113
}
127
114
}
128
- } else {
129
- eprintln ! (
130
- "Failed to read directory: {}" ,
131
- extracted_template_path. display( )
132
- ) ;
133
- continue ;
134
115
}
135
116
136
- let options = CopyOptions :: new ( ) ;
137
-
138
- match fs_extra:: copy_items ( & entries, & target_path, & options) {
117
+ match fs_extra:: copy_items ( & entries, & target_path, & CopyOptions :: new ( ) ) {
139
118
Ok ( _) => {
140
119
cliclack:: outro ( "All finished, thanks for using CM-IV CLI!" . green ( ) ) . unwrap ( ) ;
141
120
}
0 commit comments