Skip to content

Commit 3567c89

Browse files
committed
Implements more command line options
1 parent 084a6d9 commit 3567c89

File tree

3 files changed

+45
-22
lines changed

3 files changed

+45
-22
lines changed

bin/psass.pl

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,34 +18,51 @@
1818

1919
# load constants from libsass
2020
use CSS::Sass qw(SASS_STYLE_NESTED);
21+
use CSS::Sass qw(SASS_STYLE_COMPRESSED);
2122

2223
####################################################################################################
2324
# config variables
2425
####################################################################################################
2526

2627
# init options
27-
my $comments = 0;
28-
my $precision = 0;
28+
my $precision;
29+
my $output_style;
30+
my $source_comments;
2931
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;
3433

3534
# define a sub to print out the version (mimic behaviour of node.js blessc)
3635
# 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;
3840

3941
# get options
4042
GetOptions (
4143
'help|h' => sub { pod2usage(1); },
4244
'version|v' => \ &version,
43-
'comments|c!' => \ $comments,
4445
'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] }
4751
);
4852

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+
4966
####################################################################################################
5067
use CSS::Sass qw(sass_compile_file sass_compile);
5168
####################################################################################################
@@ -59,10 +76,11 @@
5976
($css, $err, $smap) = sass_compile_file(
6077
$ARGV[0],
6178
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,
6482
source_map_file => $source_map_file,
65-
omit_source_map_url => $omit_src_map_url
83+
omit_source_map_url => $omit_src_map_url,
6684
);
6785
}
6886
# or use standard input
@@ -71,10 +89,11 @@
7189
($css, $err, $smap) = sass_compile(
7290
join('', <STDIN>),
7391
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,
7695
source_map_file => $source_map_file,
77-
omit_source_map_url => $omit_src_map_url
96+
omit_source_map_url => $omit_src_map_url,
7897
);
7998
}
8099

@@ -101,15 +120,17 @@ =head1 NAME
101120
102121
=head1 SYNOPSIS
103122
104-
sass [options] [ source | - ]
123+
psass [options] [ source | - ]
105124
106125
Options:
107126
-v, --version print version
108127
-h, --help print this help
109128
-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
113134
114135
=head1 OPTIONS
115136

lib/CSS/Sass.pm

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ our @EXPORT = qw(
3333
SASS2SCSS_CONVERT_COMMENT
3434
);
3535

36-
our $VERSION = v0.8.1; # Always keep the rightmost digit, even if it's zero (stupid perl).
36+
our $VERSION = "v3.0.0";
3737

3838
require XSLoader;
3939
XSLoader::load('CSS::Sass', $VERSION);
@@ -55,6 +55,7 @@ sub last_error {
5555

5656
sub sass_compile {
5757
my ($sass_code, %options) = @_;
58+
no warnings 'uninitialized';
5859
my $r = compile_sass($sass_code, { %options,
5960
# Override sass_functions with the arrayref of arrayrefs that the XS expects.
6061
!$options{sass_functions} ? ()
@@ -70,6 +71,7 @@ sub sass_compile {
7071

7172
sub sass_compile_file {
7273
my ($input_path, %options) = @_;
74+
no warnings 'uninitialized';
7375
my $r = compile_sass_file($input_path, { %options,
7476
# Override sass_functions with the arrayref of arrayrefs that the XS expects.
7577
!$options{sass_functions} ? ()

t/99_sass_specs.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ BEGIN
99
{
1010

1111
our $todo = 0;
12-
my $skip_todo = 0;
12+
my $skip_todo = 1;
1313

1414
@dirs = ('t/sass-spec/spec');
1515

0 commit comments

Comments
 (0)