Commit 49df26ea3b89adefef01fd20586cb8dd699e8691

Authored by Göran Krampe
1 parent 33f6041b

Updated for new Nim

blimp.nim
@@ -14,7 +14,7 @@ import md5, os, osproc, parseopt2, strutils, parsecfg, streams, lapp, subexes, t @@ -14,7 +14,7 @@ import md5, os, osproc, parseopt2, strutils, parsecfg, streams, lapp, subexes, t
14 14
15 const 15 const
16 versionMajor* = 0 16 versionMajor* = 0
17 - versionMinor* = 4 17 + versionMinor* = 5
18 versionPatch* = 0 18 versionPatch* = 0
19 versionAsString* = $versionMajor & "." & $versionMinor & "." & $versionPatch 19 versionAsString* = $versionMajor & "." & $versionMinor & "." & $versionPatch
20 20
@@ -307,14 +307,14 @@ proc deflate(filename: string) = @@ -307,14 +307,14 @@ proc deflate(filename: string) =
307 if verbose: echo("\t" & filename & " deflated.") 307 if verbose: echo("\t" & filename & " deflated.")
308 308
309 # Iterator over all deflated files in the git clone 309 # Iterator over all deflated files in the git clone
310 -iterator allDeflated() = 310 +iterator allDeflated(): string =
311 let filenames = cmd("git ls-files " & gitRootDir).split({'\l', '\c'}) 311 let filenames = cmd("git ls-files " & gitRootDir).split({'\l', '\c'})
312 for fn in filenames: 312 for fn in filenames:
313 if not blimpFilename(fn).isNil: 313 if not blimpFilename(fn).isNil:
314 yield fn 314 yield fn
315 315
316 # Iterator over all files matching the blimp filter in the git clone 316 # Iterator over all files matching the blimp filter in the git clone
317 -iterator allFiltered() = 317 +iterator allFiltered(): string =
318 let lines = cmd("git ls-files | git check-attr --stdin filter").split({'\l', '\c'}) 318 let lines = cmd("git ls-files | git check-attr --stdin filter").split({'\l', '\c'})
319 for line in lines: 319 for line in lines:
320 let status = line.split(':') 320 let status = line.split(':')
blimp.nimble
1 [Package] 1 [Package]
2 name = "blimp" 2 name = "blimp"
3 -version = "0.4" 3 +version = "0.5"
4 author = "Göran Krampe" 4 author = "Göran Krampe"
5 description = "Utility that helps with big files in git, very similar to git-fat, s3annnex etc." 5 description = "Utility that helps with big files in git, very similar to git-fat, s3annnex etc."
6 license = "MIT" 6 license = "MIT"
@@ -8,5 +8,5 @@ license = "MIT" @@ -8,5 +8,5 @@ license = "MIT"
8 bin = blimp 8 bin = blimp
9 9
10 [Deps] 10 [Deps]
11 -Requires: "nimrod >= 0.10"  
12 -Requires: "lapp >= 0.1.0" 11 +Requires: "nimrod >= 0.15"
  12 +#Requires: "lapp >= 0.1.0"
lapp.nim
@@ -134,7 +134,7 @@ var @@ -134,7 +134,7 @@ var
134 parm_spec = initTable[string,PSpec]() 134 parm_spec = initTable[string,PSpec]()
135 135
136 proc fail(msg: string) = 136 proc fail(msg: string) =
137 - stderr.writeln(progname & ": " & msg) 137 + stderr.writeLine(progname & ": " & msg)
138 quit(usage) 138 quit(usage)
139 139
140 proc parseSpec(u: string) = 140 proc parseSpec(u: string) =
@@ -254,7 +254,7 @@ proc parseArguments*(usage: string, args: seq[string]): Table[string,PValue] = @@ -254,7 +254,7 @@ proc parseArguments*(usage: string, args: seq[string]): Table[string,PValue] =
254 fail("no such option: " & c) 254 fail("no such option: " & c)
255 255
256 proc get_spec(name: string): PSpec = 256 proc get_spec(name: string): PSpec =
257 - result = parm_spec[name] 257 + result = parm_spec.getOrDefault(name)
258 if result == nil: 258 if result == nil:
259 fail("no such option: " & name) 259 fail("no such option: " & name)
260 260
@@ -374,7 +374,7 @@ proc parseArguments*(usage: string, args: seq[string]): Table[string,PValue] = @@ -374,7 +374,7 @@ proc parseArguments*(usage: string, args: seq[string]): Table[string,PValue] =
374 pval = fileValue(f,value) 374 pval = fileValue(f,value)
375 else: discard 375 else: discard
376 376
377 - var oval = vars[flag] 377 + var oval = vars.getOrDefault(flag)
378 if info.multiple: # multiple flags are sequence values 378 if info.multiple: # multiple flags are sequence values
379 if oval == nil: # first value! 379 if oval == nil: # first value!
380 pval = seqValue(@[pval]) 380 pval = seqValue(@[pval])
@@ -440,11 +440,11 @@ when isMainModule: @@ -440,11 +440,11 @@ when isMainModule:
440 let v = verbosityLevel(args) 440 let v = verbosityLevel(args)
441 441
442 echo "Lines to show: " & $n 442 echo "Lines to show: " & $n
443 - echo "Verbosity level: " & $verbosityLevel(args) 443 + echo "Verbosity level: " & $v
444 444
445 let myfiles = args["files"].asSeq 445 let myfiles = args["files"].asSeq
446 var outFile = args["out"].asFile 446 var outFile = args["out"].asFile
447 447
448 for f in myfiles: 448 for f in myfiles:
449 for i in 1..n: 449 for i in 1..n:
450 - writeln(outFile, string(f.asFile.readLine())) 450 + writeLine(outFile, string(f.asFile.readLine()))