Skip to content

Commit d694d29

Browse files
committed
Minor changes
1 parent 6b5e7dd commit d694d29

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

src/packages.nim

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,33 +41,33 @@ proc parseInfo*(name: string): Package =
4141
continue
4242

4343
if line.contains("= \"") or line.contains(" =\"") or '=' notin line:
44-
abort(&"""{"name":8}{&"wrong format":48}""")
44+
abort(&"""{"name":8}{"whitespace found":48}""")
4545

4646
let
4747
pair = line.split('=', 1)
4848
key = pair[0]
49-
var value = pair[1]
49+
var val = pair[1]
5050

51-
if not (value.startsWith('"') and value.endsWith('"')):
52-
abort(&"""{"name":8}{&"wrong format":48}""")
51+
if not (val.startsWith('"') and val.endsWith('"')):
52+
abort(&"""{"name":8}{"quotes not found":48}""")
5353

54-
value = value.strip(chars = {'"'})
54+
val = val.strip(chars = {'"'})
5555

5656
case key
5757
of "ver":
58-
result.ver = value
58+
result.ver = val
5959
of "url":
60-
result.url = value
60+
result.url = val
6161
of "sum":
62-
result.sum = value
62+
result.sum = val
6363
of "bld":
64-
result.bld = value
64+
result.bld = val
6565
of "run":
66-
result.run = value
66+
result.run = val
6767
of "opt":
68-
result.opt = value
68+
result.opt = val
6969
else:
70-
abort(&"""{"name":8}{&"wrong format":48}""")
70+
abort(&"""{"name":8}{&"\{key\} not found":48}""")
7171

7272
proc printContent(idx: int, name, ver, cmd: string) =
7373
echo &"""{idx + 1:<8}{name:24}{ver:24}{cmd:8}""" & now().format("hh:mm tt")
@@ -327,10 +327,8 @@ proc listPackages*() =
327327
showInfo(walkDir(pkgCache, true, skipSpecial = true).toSeq().unzip()[1].sorted())
328328

329329
proc listContents*(packages: openArray[string]) =
330-
for name in packages.deduplicate():
331-
let package = parseInfo(name)
332-
333-
for line in lines(pkgCache / name / "contents"):
330+
for package in packages.deduplicate():
331+
for line in lines(pkgCache / package / "contents"):
334332
echo &"/{line}"
335333

336334
proc searchPackages*(pattern: openArray[string]) =

0 commit comments

Comments
 (0)