Added tasklists to help, no longer printing warnings in case of missing commands.
h3rald h3rald@h3rald.com
Sat, 19 Sep 2020 11:29:24 +0200
5 files changed,
19 insertions(+),
6 deletions(-)
M
Nifty_UserGuide.md
→
Nifty_UserGuide.md
@@ -428,7 +428,7 @@
The following sections describe the default system commands. Unlike [custom commands](#Default-custom-commands), system commands _cannot_ be customized and do not require external programs to run. {#command||help||help [<command>]|| -Display help on the specified command (or all commands). +Display help on the specified command (or all tasklists and commands). #} {#command||info||info <package>||
M
src/nifty.nim
→
src/nifty.nim
@@ -3,6 +3,7 @@ json,
os, parseopt, logging, + algorithm, strutils, sequtils@@ -245,9 +246,11 @@ echo "$1:\t$2" % [k, $v]
of "help": echo "" if args.len < 2: - for k, v in prj.help.pairs: - printGreen " nifty $1" % v["_syntax"].getStr - echo "\n $1\n" % v["_description"].getStr + var sortedKeys = toSeq(prj.help.keys) + sortedKeys.sort(cmp[string]) + for k in sortedKeys: + printGreen " nifty $1" % prj.help[k]["_syntax"].getStr + echo "\n $1\n" % prj.help[k]["_description"].getStr else: let cmd = args[1] let help = prj.help[cmd]
M
src/niftypkg/config.nim
→
src/niftypkg/config.nim
@@ -1,5 +1,5 @@
const pkgTitle* = "nifty" - pkgVersion* = "1.2.0" + pkgVersion* = "1.2.1" pkgAuthor* = "Fabio Cevasco" pkgDescription* = "A decentralized (pseudo) package manager and script runner."
M
src/niftypkg/nifty.json
→
src/niftypkg/nifty.json
@@ -1,5 +1,6 @@
{ "storage": "$1", + "tasklists": {}, "commands": { "install":
M
src/niftypkg/project.nim
→
src/niftypkg/project.nim
@@ -52,6 +52,15 @@ proc help*(prj: var NiftyProject): JsonNode =
result = systemHelp.parseJson if prj.configured: prj.load + for k, v in prj.tasklists.pairs: + let syntax = "$$$1" % k + let description = "Executes: $1" % v.elems.mapIt(it.getStr).join(", ") + result["$"&k] = (""" + { + "_syntax": "$1", + "_description": "$2" + } + """ % [syntax, description]).parseJson for k, v in prj.commands.pairs: if v.hasKey("_syntax") and v.hasKey("_description"): result[k] = ("""@@ -138,7 +147,7 @@ pwd.createDir()
pwd.setCurrentDir() result = execShellCmd cmd else: - warn "Command '$1' not available for package '$2'" % [command, alias] + debug "Command '$1' not available for package '$2'" % [command, alias] setCurrentDir(prj.dir) proc executeRec*(prj: var NiftyProject, command, alias: string) =