18
18
19
19
# load constants from libsass
20
20
use CSS::Sass qw( SASS_STYLE_NESTED) ;
21
+ use CSS::Sass qw( SASS_STYLE_COMPRESSED) ;
21
22
22
23
# ###################################################################################################
23
24
# config variables
24
25
# ###################################################################################################
25
26
26
27
# init options
27
- my $comments = 0;
28
- my $precision = 0;
28
+ my $precision ;
29
+ my $output_style ;
30
+ my $source_comments ;
29
31
my $source_map_file ;
30
- my $omit_src_map_url = 0;
31
-
32
- # make this configurable
33
- my $style = SASS_STYLE_NESTED;
32
+ my $omit_src_map_url ;
34
33
35
34
# define a sub to print out the version (mimic behaviour of node.js blessc)
36
35
# this script has it's own version numbering as it's not dependent on any libs
37
- sub version { print " psass 0.1.0 (perl sass (scss) compiler)" ; exit 0; };
36
+ sub version { print " psass 0.3.0 (perl sass (scss) compiler)" ; exit 0; };
37
+
38
+ # include paths
39
+ my @include_paths ;
38
40
39
41
# get options
40
42
GetOptions (
41
43
' help|h' => sub { pod2usage(1); },
42
44
' version|v' => \ &version,
43
- ' comments|c!' => \ $comments ,
44
45
' precision|p=s' => \ $precision ,
45
- ' source_map|s=s' => \ $source_map_file ,
46
- ' omit_source_map!' => \ $omit_src_map_url ,
46
+ ' output-style|t=s' => \ $output_style ,
47
+ ' source-comments|c!' => \ $source_comments ,
48
+ ' source-map-file|m=s' => \ $source_map_file ,
49
+ ' omit-source-map_url|M!' => \ $omit_src_map_url ,
50
+ ' include-path|I=s' => sub { push @include_paths , $_ [1] }
47
51
);
48
52
53
+ # set default if not configured
54
+ unless (defined $output_style )
55
+ { $output_style = SASS_STYLE_NESTED }
56
+
57
+ # parse string to constant
58
+ if ($output_style =~ m / ^n/ i )
59
+ { $output_style = SASS_STYLE_NESTED }
60
+ elsif ($output_style =~ m / ^c/ i )
61
+ { $output_style = SASS_STYLE_COMPRESSED }
62
+ # die with message if style is unknown
63
+ else { die " unknown output style: $output_style " }
64
+
65
+
49
66
# ###################################################################################################
50
67
use CSS::Sass qw( sass_compile_file sass_compile) ;
51
68
# ###################################################################################################
59
76
($css , $err , $smap ) = sass_compile_file(
60
77
$ARGV [0],
61
78
precision => $precision ,
62
- output_style => $style ,
63
- source_comments => $comments ,
79
+ output_style => $output_style ,
80
+ include_paths => \ @include_paths ,
81
+ source_comments => $source_comments ,
64
82
source_map_file => $source_map_file ,
65
- omit_source_map_url => $omit_src_map_url
83
+ omit_source_map_url => $omit_src_map_url ,
66
84
);
67
85
}
68
86
# or use standard input
71
89
($css , $err , $smap ) = sass_compile(
72
90
join (' ' , <STDIN >),
73
91
precision => $precision ,
74
- output_style => $style ,
75
- source_comments => $comments ,
92
+ output_style => $output_style ,
93
+ include_paths => \ @include_paths ,
94
+ source_comments => $source_comments ,
76
95
source_map_file => $source_map_file ,
77
- omit_source_map_url => $omit_src_map_url
96
+ omit_source_map_url => $omit_src_map_url ,
78
97
);
79
98
}
80
99
@@ -101,15 +120,17 @@ =head1 NAME
101
120
102
121
=head1 SYNOPSIS
103
122
104
- sass [options] [ source | - ]
123
+ psass [options] [ source | - ]
105
124
106
125
Options:
107
126
-v, --version print version
108
127
-h, --help print this help
109
128
-p, --precision precision for float output
110
- -c, --comments enable source debug comments
111
- -s, --source_map=file create and write source map to file
112
- --omit_source_map_url disable adding source map url comment
129
+ -t, --output-style=style output style [nested|compressed]
130
+ -I, --include-path=path sass include path (repeatable)
131
+ -c, --source-comments enable source debug comments
132
+ -m, --source-map-file=file create and write source map to file
133
+ --omit-source-map-url omit sourceMappingUrl from output
113
134
114
135
=head1 OPTIONS
115
136
0 commit comments