Remove escaping of author name and package description in nimble init,

since it replaces characters used in many names and languages with
escape sequences.
Slightly refactor the code for determining author name, to make it
easier to add other version control systems in future (right now it's
just git and hg).

Also, add some binary test artifacts to .gitignore so they don't accidentally
get committed in future.
This commit is contained in:
Oisín Mac Fhearaí 2019-07-27 17:55:59 +01:00 committed by Dominik Picheta
commit 5b7b061465
3 changed files with 22 additions and 13 deletions

11
.gitignore vendored
View file

@ -12,6 +12,14 @@ nimcache/
/nimble /nimble
/tests/nimscript/nimscript /tests/nimscript/nimscript
/tests/issue27/issue27 /tests/issue27/issue27
src/nimblepkg/cli
src/nimblepkg/packageinfo
src/nimblepkg/packageparser
src/nimblepkg/reversedeps
src/nimblepkg/version
tests/nimble-test/
tests/packageStructure/validBinary/y
tests/testCommand/testsFail/tests/t2
# Windows executables # Windows executables
*.exe *.exe
@ -19,4 +27,5 @@ nimcache/
# VCC compiler and linker artifacts # VCC compiler and linker artifacts
*.ilk *.ilk
*.pdb *.pdb

View file

@ -724,20 +724,20 @@ proc init(options: Options) =
display("Using", "$# for new package name" % [pkgName.escape()], display("Using", "$# for new package name" % [pkgName.escape()],
priority = HighPriority) priority = HighPriority)
# Ask for package author # Determine author by running an external command
proc getAuthorWithCmd(cmd: string): string =
let (name, exitCode) = doCmdEx(cmd)
if exitCode == QuitSuccess and name.len > 0:
result = name.strip()
display("Using", "$# for new package author" % [result],
priority = HighPriority)
# Determine package author via git/hg or asking
proc getAuthor(): string = proc getAuthor(): string =
if findExe("git") != "": if findExe("git") != "":
let (name, exitCode) = doCmdEx("git config --global user.name") result = getAuthorWithCmd("git config --global user.name")
if exitCode == QuitSuccess and name.len > 0:
result = name.strip()
display("Using", "$# for new package author" % [result.escape()],
priority = HighPriority)
elif findExe("hg") != "": elif findExe("hg") != "":
let (name, exitCode) = doCmdEx("hg config ui.username") result = getAuthorWithCmd("hg config ui.username")
if exitCode == QuitSuccess and name.len > 0:
result = name.strip()
display("Using", "$# for new package author" % [result.escape()],
priority = HighPriority)
if result.len == 0: if result.len == 0:
result = promptCustom(options, "Your name?", "Anonymous") result = promptCustom(options, "Your name?", "Anonymous")
let pkgAuthor = getAuthor() let pkgAuthor = getAuthor()

View file

@ -175,7 +175,7 @@ $#
requires "nim >= $#" requires "nim >= $#"
""" % [ """ % [
info.pkgVersion.escape(), info.pkgAuthor.escape(), info.pkgDesc.escape(), info.pkgVersion.escape(), info.pkgAuthor, info.pkgDesc.escape(),
info.pkgLicense.escape(), info.pkgSrcDir.escape(), nimbleFileOptions, info.pkgLicense.escape(), info.pkgSrcDir.escape(), nimbleFileOptions,
pkgBackend, info.pkgNimDep pkgBackend, info.pkgNimDep
] ]