Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

console: write more things to stderr #208

Merged
merged 2 commits into from
Mar 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/cli.nim
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,12 @@ proc showHelp(exitCode: range[0..255] = 0) =
const helpText = genHelpText()
let appName = extractFilename(getAppFilename())
let usage = "Usage:\n" &
&" {appName} [global-options] <command> [command-options]\n\n"
stdout.write usage
echo helpText
&" {appName} [global-options] <command> [command-options]\n"
let f = if exitCode == 0: stdout else: stderr
f.writeLine usage
f.writeLine helpText
if f == stdout:
f.flushFile()
quit(exitCode)

proc showVersion =
Expand Down
7 changes: 3 additions & 4 deletions tests/test_binary.nim
Original file line number Diff line number Diff line change
Expand Up @@ -271,13 +271,12 @@ proc main =
const helpStart = &"Usage:\n {binaryName} [global-options] <command> [command-options]"

const cmd = "nimble --verbose build -d:release"
stdout.write(&"Running `{cmd}`... ")
stdout.flushFile()
stderr.write(&"Running `{cmd}`... ")
ee7 marked this conversation as resolved.
Show resolved Hide resolved
let (buildOutput, buildExitCode) = execCmdEx(cmd, workingDir = repoRootDir)
if buildExitCode == 0:
echo "success"
stderr.writeLine "success"
ee7 marked this conversation as resolved.
Show resolved Hide resolved
else:
echo "failure"
stderr.writeLine "failure"
raise newException(OSError, buildOutput)

suite "help as an argument":
Expand Down