-
Notifications
You must be signed in to change notification settings - Fork 7
/
faker.nimble
63 lines (51 loc) · 1.44 KB
/
faker.nimble
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# Package
version = "0.16.0"
author = "jiro4989"
description = "faker is a Nim package that generates fake data for you."
license = "MIT"
srcDir = "src"
installExt = @["nim"]
bin = @["faker/cli/faker"]
binDir = "bin"
from os import `/`, splitFile
from algorithm import sort
import strformat, strutils, sequtils
# Dependencies
requires "nim >= 1.0.0"
let
providerDir = "src" / "faker" / "provider"
task tests, "Run test":
exec "testament p 'tests/test_*.nim'"
task docs, "Generate API documents":
exec "nimble doc --index:on --project --out:docs --hints:off src/faker.nim"
task genMod, "Generate module":
let module = paramStr(paramCount())
if module == "genMod":
echo "Need 1 args"
quit 1
# Copy module dir
let
srcModule = "job"
srcDir = providerDir / srcModule
dstDir = providerDir / module
rmDir dstDir
cpDir srcDir, dstDir
echo "Generated: " & module
# Copy module index file
let
srcFile = srcDir & ".nim"
dstFile = dstDir & ".nim"
rmFile dstFile
cpFile srcFile, dstFile
echo "Generated: " & dstFile
# Rename module name
for path in listFiles(dstDir):
let (dir, name, ext) = splitFile(path)
if name == "interfaces":
continue
let newName = name.replace(srcModule, module)
let newPath = dir / newName & ext
mvFile path, newPath
echo "Generated: " & newPath
task tool, "Build tools":
exec "nim c tools/generator.nim"