Skip to content

Commit

Permalink
adding cmd line indent option
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredly committed Jun 24, 2010
1 parent bd72678 commit 7160919
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions bin/ccss
Expand Up @@ -39,6 +39,8 @@ def main():
help='convert css files to ccss')
parser.add_option('--minified', action='store_true',
help='minify the resulting css')
parser.add_option('-i', '--indent', dest='indent', type='int',
default=2, help='number of spaces to indent (default 2)')

(options, args) = parser.parse_args()
if options.eigen_test:
Expand All @@ -51,7 +53,7 @@ def main():
elif len(args):
convert_many(args, options)
else:
convert_stream()
convert_stream(options)

def do_test():
rx = re.compile(r'Example::\n(.*?)__END__(?ms)')
Expand All @@ -64,10 +66,10 @@ def list_colors():
for color in sorted(clevercss.consts.COLORS.items()):
print ' %-30s%s' % color

def convert_stream():
def convert_stream(options):
import sys
try:
print clevercss.convert(sys.stdin.read())
print clevercss.convert(sys.stdin.read(), indent=options.indent)
except (ParseError, TranslateError), e:
sys.stderr.write('Error: %s\n' % e)
sys.exit(1)
Expand All @@ -89,7 +91,7 @@ def convert_many(files, options):
src = open(fname)
try:
try:
converted = clevercss.convert(src.read(), fname=fname)
converted = clevercss.convert(src.read(), fname=fname, indent=options.indent)
except (ParseError, TranslateError), e:
sys.stderr.write('Error in file %s: %s\n' % (fname, e))
sys.exit(1)
Expand Down

0 comments on commit 7160919

Please sign in to comment.