Skip to content

Commit

Permalink
Merge pull request #9 from Yamato-Security/8-check-yml-files-list-in-…
Browse files Browse the repository at this point in the history
…target-folder

Check yml files list in target folder
  • Loading branch information
hitenkoku committed Sep 30, 2022
2 parents 94de2e1 + d3125a1 commit 30e7d0e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/takajo.nim
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,12 @@ Options:

when isMainModule:
let args = docopt(doc)
if args["c"] == true and not args["<CSV-FILE>"]:
if args["<CSV-FILE>"]:
let csvData = getHayabusaCsvData($args["<CSV-FILE>"])
if args["<hayabusa-rulespath>"]:
let rulePath: string = args["<hayabusa-rulespath>"]
for f in walkDirRec(rulePath, "*.yml"):

if args["c"] == true and args["<column>"]:
let targetColumn = args["<column>"]
csvData[targetColumn]
9 changes: 9 additions & 0 deletions src/takajopkg/submodule.nim
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,17 @@

import std/tables
import std/parsecsv
import std/os
import std/strutils
from std/streams import newFileStream

proc getYMLLists*(targetDirPath: string): seq[string] =
var r: seq[string] = @[]
for f in walkDirRec(targetDirPath):
if f.endsWith(".yml"):
r.insert(f)
return r

proc getHayabusaCsvData*(csvPath: string): Tableref[string, seq[string]] =
## procedure for Hayabusa output csv read data.

Expand Down
3 changes: 3 additions & 0 deletions tests/testsubmodule.nim
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ test "csv file path import":
writeFile("temp.csv", expect_content)
check getHayabusaCsvData("./tests/data/1.csv") == expect_table

test "check getYMLLists":
let expect = @["tests\\data\\1.yml"]
check getYMLLists("./tests") == expect

0 comments on commit 30e7d0e

Please sign in to comment.