summary refs log tree commit diff stats
path: root/nimpretty
diff options
context:
space:
mode:
Diffstat (limited to 'nimpretty')
-rw-r--r--nimpretty/nimpretty.nim7
1 files changed, 6 insertions, 1 deletions
diff --git a/nimpretty/nimpretty.nim b/nimpretty/nimpretty.nim
index ca40ccdb5..e0b27c231 100644
--- a/nimpretty/nimpretty.nim
+++ b/nimpretty/nimpretty.nim
@@ -18,7 +18,7 @@ import ../compiler / [idents, msgs, ast, syntaxes, renderer, options,
 import parseopt, strutils, os
 
 const
-  Version = "0.1"
+  Version = "0.2"
   Usage = "nimpretty - Nim Pretty Printer Version " & Version & """
 
   (c) 2017 Andreas Rumpf
@@ -28,6 +28,7 @@ Options:
   --output:file         set the output file (default: overwrite the input file)
   --indent:N[=0]        set the number of spaces that is used for indentation
                         --indent:0 means autodetection (default behaviour)
+  --maxLineLen:N        set the desired maximum line length (default: 80)
   --version             show the version
   --help                show this help
 """
@@ -45,6 +46,7 @@ proc writeVersion() =
 type
   PrettyOptions = object
     indWidth: int
+    maxLineLen: int
 
 proc prettyPrint(infile, outfile: string, opt: PrettyOptions) =
   var conf = newConfigRef()
@@ -55,6 +57,7 @@ proc prettyPrint(infile, outfile: string, opt: PrettyOptions) =
   var p: TParsers
   p.parser.em.indWidth = opt.indWidth
   if setupParsers(p, fileIdx, newIdentCache(), conf):
+    p.parser.em.maxLineLen = opt.maxLineLen
     discard parseAll(p)
     closeParsers(p)
 
@@ -66,6 +69,7 @@ proc main =
     # if input is not actually over-written, when nimpretty is a noop).
     # --backup was un-documented (rely on git instead).
   var opt: PrettyOptions
+  opt.maxLineLen = 80
   for kind, key, val in getopt():
     case kind
     of cmdArgument:
@@ -77,6 +81,7 @@ proc main =
       of "backup": backup = parseBool(val)
       of "output", "o": outfile = val
       of "indent": opt.indWidth = parseInt(val)
+      of "maxlinelen": opt.maxLineLen = parseInt(val)
       else: writeHelp()
     of cmdEnd: assert(false) # cannot happen
   if infile.len == 0: