Compare commits

..

No commits in common. "master" and "1.0.0" have entirely different histories.

3 changed files with 11 additions and 28 deletions

View File

@ -1,6 +1,4 @@
import cliutils, cstrutils, docopt, linenoise, os, osproc, sequtils, strutils
import "./version.nim"
import cliutils, linenoise, os, osproc, sequtils, strutils
proc writeOutput(msg, errMsg: TaintedString, cmd: string): void =
if not msg.isEmptyOrWhitespace: stdout.writeLine(msg)
@ -8,18 +6,15 @@ proc writeOutput(msg, errMsg: TaintedString, cmd: string): void =
when isMainModule:
let usage = """
Usage:
cmd_shell [--prepend-args] <cmd> [-- <args>...]
"""
# Parse arguments
let args = docopt(usage, version = CMD_SHELL_VERSION)
if paramCount() == 0:
stderr.writeLine "cmd_shell: no arguments"
quit(QuitFailure)
let cmdPrompt = $args["<cmd>"]
let cmdPrompt = paramStr(1)
let cmd = '"' & cmdPrompt & '"'
let argsForCmd =
if args["<args>"]: @(args["<args>"]).mapIt("'" & $it & "'").join(" ")
let args =
if paramCount() > 1: commandLineParams()[1..^1].mapIt("'" & $it & "'").join(" ")
else: ""
discard historySetMaxLen(
@ -28,10 +23,7 @@ Usage:
var line = readLine(cmdPrompt & "> ")
while line != nil and cmpIgnoreCase(line, "exit") != 0:
if args["--prepend-args"]:
discard exec(cmd & " " & argsForCmd & " " & $line, "", [], nil, {poUsePath, poEvalCommand}, writeOutput)
else:
discard exec(cmd & " " & $line & " " & argsForCmd, "", [], nil, {poUsePath, poEvalCommand}, writeOutput)
while line != nil:
discard exec(cmd & " " & args & $line, "", [], nil, {poUsePath, poEvalCommand}, writeOutput)
historyAdd(line)
line = readLine(cmdPrompt & "> ")

View File

@ -1,6 +1,6 @@
# Package
version = "1.2.0"
version = "1.0.0"
author = "Jonathan Bernard"
description = "Wrapper around CLI commands (passing input as arguments)."
license = "MIT"
@ -8,12 +8,4 @@ bin = @["cmd_shell"]
# Dependencies
requires @[
"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'"
requires @["nim >= 0.16.1", "cliutils"]

View File

@ -1 +0,0 @@
const CMD_SHELL_VERSION* = "1.2.0"