all repos — nifty @ a65b2760226c6e49d2ee427973d3d3561dc268bb

A tiny (pseudo) package manager and script runner.

Implemented purge command.
h3rald h3rald@h3rald.com
Sun, 21 Oct 2018 16:29:28 +0200
commit

a65b2760226c6e49d2ee427973d3d3561dc268bb

parent

db501108b473e4b4d9e95a6efde7325cfcdf2038

4 files changed, 19 insertions(+), 4 deletions(-)

jump to
M Nifty_UserGuide.mdNifty_UserGuide.md

@@ -423,6 +423,9 @@ Configures a new or existing package <package>.

The configuration of the package properly is interactive: {{n}} will prompt whether you want to add or modify properties.#} +{#command||purge||purge|| +Deletes the storage directory and all its contents.#} + {#command||remove||remove [<package>]|| Physically deletes the specified package (or all packages) from the storage directory.
M src/nifty.nimsrc/nifty.nim

@@ -29,10 +29,12 @@

Options: --log, -l Specifies the log level (debug|info|notice|warn|error|fatal). Default: info + --force, -f Do not ask for confirmation when executing the specified command. --help, -h Displays this message. --version, -h Displays the version of the application. """ % [pkgTitle, pkgVersion, pkgDescription, pkgAuthor] +var force = false # Helper Methods

@@ -77,12 +79,12 @@ printAdded(newv.label, $newv.value)

return confirm("Confirm change?") proc confirmAndRemoveDir(dir: string) = - let answer = confirm "Delete directory '$1' and all its contents?" % dir + let answer = force or confirm "Delete directory '$1' and all its contents?" % dir if answer: dir.removeDir() proc confirmAndRemoveFile(file: string) = - let answer = confirm "Delete file '$1'? [y/n]" % file + let answer = force or confirm "Delete file '$1'? [y/n]" % file if answer: file.removeFile()

@@ -146,6 +148,8 @@ of cmdArgument:

args.add key of cmdLongOption, cmdShortOption: case key: + of "force", "f": + force = true of "log", "l": var val = val setLogLevel(val)

@@ -175,6 +179,9 @@ if args.len > 2:

storage = args[1] prj.init(storage) notice "Project initialized using '$1' as storage directory." % storage + of "purge": + prj.load + confirmAndRemoveDir(prj.dir/prj.storage) of "map": if args.len < 2: fatal "No package specified."

@@ -207,7 +214,7 @@ prj.load

if not prj.packages.hasKey(alias): fatal "Package '$1' not defined." % [alias] quit(4) - if confirm("Remove mapping for package '$1'?" % alias): + if force or confirm("Remove mapping for package '$1'?" % alias): prj.unmap(alias) of "remove": prj.load
M src/niftypkg/config.nimsrc/niftypkg/config.nim

@@ -1,5 +1,5 @@

const pkgTitle* = "nifty" - pkgVersion* = "1.0.1" + pkgVersion* = "1.1.0" pkgAuthor* = "Fabio Cevasco" pkgDescription* = "A decentralized (pseudo) package manager and script runner."
M src/niftypkg/help.jsonsrc/niftypkg/help.json

@@ -24,6 +24,11 @@ {

"_syntax": "map <package>", "_description": "Configures a new or existing package <package>." }, + "purge": + { + "_syntax": "purge", + "_description": "Deletes the storage directory and all its contents." + }, "remove": { "_syntax": "remove [<package>]",