-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscp.rs
55 lines (43 loc) · 1.18 KB
/
scp.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
use std::env;
use std::env::args;
fn main() {
// Collect arguments
let arguments: Vec<_> = env::args().collect();
// Create symbol variable
let symbol;
// Check if user given an argument
// If true, the argument will be used as the symbol,
if arguments.len() > 1 {
let symbol_arg:String = args().nth(1).unwrap();
symbol = symbol_arg;
// Otherwise check for an environment variable 'CCC_SYMBOL',
// If the variable exists, use it as the symbol, if not,
// a rust symbol will be used.
} else {
match env::var("CCC_SYMBOL") {
Ok(val) => symbol = val,
Err(_e) => symbol = "".to_string(),
}
}
// The rest is iterating the 'count variable and using
// Escape characters to colorize the symbol
let mut count = 0u32;
print!("\n");
loop {
count += 1;
print!(" \x1B[{}m{} \x1B[m", 29 + count, symbol);
if count == 8 {
break;
}
}
print!("\n");
count = 0;
loop {
count += 1;
print!(" \x1B[{}m{} \x1B[m", 89 + count, symbol);
if count == 8 {
break;
}
}
print!("\n\n");
}