Compare commits
No commits in common. "master" and "0.1.0" have entirely different histories.
@ -1,25 +1,20 @@
|
|||||||
import cliutils, cstrutils, docopt, linenoise, os, osproc, sequtils, strutils
|
import cliutils, linenoise, os, osproc, sequtils, strutils
|
||||||
|
|
||||||
import "./version.nim"
|
|
||||||
|
|
||||||
proc writeOutput(msg, errMsg: TaintedString, cmd: string): void =
|
proc writeOutput(msg, errMsg: TaintedString, cmd: string): void =
|
||||||
if not msg.isEmptyOrWhitespace: stdout.writeLine(msg)
|
if msg != nil: stdout.writeLine(msg)
|
||||||
if not errMsg.isEmptyOrWhitespace: stderr.writeLine(errMsg)
|
if errMsg != nil: stderr.writeLine(errMsg)
|
||||||
|
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
|
|
||||||
let usage = """
|
if paramCount() == 0:
|
||||||
Usage:
|
stderr.writeLine "cmd_shell: no arguments"
|
||||||
cmd_shell [--prepend-args] <cmd> [-- <args>...]
|
quit(QuitFailure)
|
||||||
"""
|
|
||||||
# Parse arguments
|
|
||||||
let args = docopt(usage, version = CMD_SHELL_VERSION)
|
|
||||||
|
|
||||||
let cmdPrompt = $args["<cmd>"]
|
let cmdPrompt = paramStr(1)
|
||||||
let cmd = '"' & cmdPrompt & '"'
|
let cmd = '"' & cmdPrompt & '"'
|
||||||
|
|
||||||
let argsForCmd =
|
let args =
|
||||||
if args["<args>"]: @(args["<args>"]).mapIt("'" & $it & "'").join(" ")
|
if paramCount() > 1: commandLineParams()[1..^1].mapIt("'" & $it & "'").join(" ")
|
||||||
else: ""
|
else: ""
|
||||||
|
|
||||||
discard historySetMaxLen(
|
discard historySetMaxLen(
|
||||||
@ -28,10 +23,8 @@ Usage:
|
|||||||
|
|
||||||
var line = readLine(cmdPrompt & "> ")
|
var line = readLine(cmdPrompt & "> ")
|
||||||
|
|
||||||
while line != nil and cmpIgnoreCase(line, "exit") != 0:
|
while line != nil:
|
||||||
if args["--prepend-args"]:
|
discard exec(cmd & " " & args & $line, "", [], nil, {poUsePath, poEvalCommand}, writeOutput)
|
||||||
discard exec(cmd & " " & argsForCmd & " " & $line, "", [], nil, {poUsePath, poEvalCommand}, writeOutput)
|
|
||||||
else:
|
|
||||||
discard exec(cmd & " " & $line & " " & argsForCmd, "", [], nil, {poUsePath, poEvalCommand}, writeOutput)
|
|
||||||
historyAdd(line)
|
historyAdd(line)
|
||||||
line = readLine(cmdPrompt & "> ")
|
line = readLine(cmdPrompt & "> ")
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# Package
|
# Package
|
||||||
|
|
||||||
version = "1.2.0"
|
version = "0.1.0"
|
||||||
author = "Jonathan Bernard"
|
author = "Jonathan Bernard"
|
||||||
description = "Wrapper around CLI commands (passing input as arguments)."
|
description = "Wrapper around CLI commands (passing input as arguments)."
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
@ -8,12 +8,4 @@ bin = @["cmd_shell"]
|
|||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
|
|
||||||
requires @[
|
requires @["nim >= 0.16.1", "cliutils"]
|
||||||
"nim >= 0.16.1",
|
|
||||||
"cliutils",
|
|
||||||
|
|
||||||
"https://git.jdb-labs.com/jdb/update-nim-package-version"
|
|
||||||
]
|
|
||||||
|
|
||||||
task updateVersion, "Update the version of this package.":
|
|
||||||
exec "update_nim_package_version cmd_shell 'version.nim'"
|
|
||||||
|
@ -1 +0,0 @@
|
|||||||
const CMD_SHELL_VERSION* = "1.2.0"
|
|
Loading…
x
Reference in New Issue
Block a user