-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.dart
More file actions
95 lines (83 loc) · 2.38 KB
/
main.dart
File metadata and controls
95 lines (83 loc) · 2.38 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import 'dart:io';
import 'package:ansicolor/ansicolor.dart';
import 'package:sass/sass.dart' as sass;
var warningFont = new AnsiPen();
var errorFont = new AnsiPen();
var infoFont = new AnsiPen();
var successFont = new AnsiPen();
var creatorFont = new AnsiPen();
var boldWhite = new AnsiPen();
Future<void> main(List<String> arguments) async {
initColors();
welcome();
if (arguments.length == 0) {
noParamters();
creator();
return;
}
if (arguments[0] == "-h") {
wrongParamters();
creator();
return;
}
if (arguments[1] == "") {
print(errorFont("You have entered wrong paramters. Please type -h to get started"));
creator();
return;
}
try {
if( ! await File(arguments[0]).exists()){
throw new FileSystemException("Could not find inputFile.");
}
var folderPath = File(arguments[1]).parent.path;
if(! await File(folderPath).exists()){
throw new FileSystemException("Could not find the outputFolder");
}
var result = sass.compile(arguments[0]);
new File(arguments[1]).writeAsStringSync(result);
print(successFont("Successfuly created!"));
creator();
} catch (e) {
print(warningFont("Something went wrong!!!"));
print(errorFont(e));
}
}
void initColors() {
warningFont
..white(bold: true)
..rgb(r: 1.0, g: 0.8, b: 0.2);
boldWhite..white(bold: true);
errorFont..red(bold: true);
infoFont..blue();
successFont..green();
creatorFont.cyan(bold: true);
}
void welcome() {
print(warningFont("================================================================="));
print("");
print(warningFont(" > Welcome to Sass Compiler !!!"));
print("");
print(warningFont("================================================================="));
print("");
}
void wrongParamters() {
print(boldWhite(" > compiler 'inputFilePath' 'outputFilePath"));
print("");
print("");
print(boldWhite("exp: compiler style.scss style.css"));
print("");
print("");
print(warningFont("Have fun!!!"));
}
void noParamters() {
print(errorFont("You didnt enter any arguments."));
print(boldWhite(" - To get started type -h"));
}
void creator() {
print("");
print(creatorFont("================================================================="));
print("");
print(creatorFont(" made by RepiatX"));
print("");
print(creatorFont("================================================================="));
}