-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
48 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import cligen | ||
|
||
import loguepkg/[create, execute] | ||
import loguepkg/[create, execute, extend] | ||
|
||
|
||
proc main*() = | ||
dispatchMulti([init], [run]) | ||
dispatchMulti([init], [run], [extension]) | ||
|
||
when isMainModule: | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import os, strformat, osproc, strutils | ||
|
||
const | ||
nimbleFile = "prologue.nimble" | ||
|
||
|
||
template withDir(dir: string; body: untyped): untyped = | ||
var curDir = getCurrentDir() | ||
try: | ||
setCurrentDir(dir) | ||
body | ||
finally: | ||
setCurrentDir(curDir) | ||
|
||
proc extension*(name: seq[string]) = | ||
if name.len == 0: | ||
echo "Please give the name of the extension or use logue extension all to install all extensions" | ||
else: | ||
# TODO May raise OsError in windows | ||
var output: string | ||
var errC: int | ||
if fileExists(nimbleFile): | ||
(output, errC) = (nimbleFile, 0) | ||
else: | ||
(output, errC) = execCmdEx("nimble path prologue") | ||
if errC == 0: | ||
stripLineEnd(output) | ||
normalizePath(output) | ||
|
||
withDir output: | ||
var errC: int | ||
|
||
let extension = name[0] | ||
|
||
if extension == "all": | ||
discard execCmd(fmt"nimble extension") | ||
else: | ||
try: | ||
errC = execCmd(fmt"nimble {extension}") | ||
except OSError: | ||
errC = 1 | ||
|
||
if errC != 0: | ||
echo "Please give the right name of the extension" | ||
else: | ||
echo "Please install prologue or check whther nimble is added to path" |