4
4
#include < cstring>
5
5
#include < sstream>
6
6
#include < iostream>
7
+ #include < stdlib.h>
7
8
8
9
#include " sass2scss.h"
9
10
@@ -18,12 +19,25 @@ int main (int argc, char** argv)
18
19
// set by command line
19
20
int pretty = 0 ;
20
21
22
+ // bitwise options
23
+ // set by command line
24
+ int options = 0 ;
25
+
21
26
// process command line arguments
22
- for (int i = 0 ; i < argc; ++i)
27
+ for (int i = 1 ; i < argc; ++i)
23
28
{
24
- // only handle prettyfying option
29
+ // handle prettyfying option
25
30
if (" -p" == string (argv[i])) pretty ++;
26
- if (" --pretty" == string (argv[i])) pretty ++;
31
+ else if (" --pretty" == string (argv[i])) pretty ++;
32
+ // handle other bitwise options (comment related)
33
+ else if (" -k" == string (argv[i])) options |= SASS2SCSS_KEEP_COMMENT;
34
+ else if (" --keep" == string (argv[i])) options |= SASS2SCSS_KEEP_COMMENT;
35
+ else if (" -s" == string (argv[i])) options |= SASS2SCSS_STRIP_COMMENT;
36
+ else if (" --strip" == string (argv[i])) options |= SASS2SCSS_STRIP_COMMENT;
37
+ else if (" -c" == string (argv[i])) options |= SASS2SCSS_CONVERT_COMMENT;
38
+ else if (" --convert" == string (argv[i])) options |= SASS2SCSS_CONVERT_COMMENT;
39
+ // error out with a generic error message (keep it simple for now)
40
+ else { cerr << " Unknown command line option " << argv[i] << endl; exit (EXIT_FAILURE); }
27
41
}
28
42
29
43
// declare variable
@@ -43,7 +57,11 @@ int main (int argc, char** argv)
43
57
if (cin.eof ()) break ;
44
58
};
45
59
60
+ // simple assertion for valid value
61
+ if (pretty > SASS2SCSS_PRETTIFY_3)
62
+ { pretty = SASS2SCSS_PRETTIFY_3; }
63
+
46
64
// print the resulting scss
47
- cout << Sass::sass2scss (sass, pretty);
65
+ cout << Sass::sass2scss (sass, pretty | options );
48
66
49
67
}
0 commit comments