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

Menu select add arrow button support #963

Merged
merged 3 commits into from
Dec 4, 2021

Conversation

elcritch
Copy link
Contributor

@elcritch elcritch commented Dec 4, 2021

Support for up & down arrows for interactive prompt. It's a pet peeve, I try and hit up/down every time Nimble prompts this way.

I didn't see any unit tests, but I tested it manually. Here's some manual test code:

import unittest
import strutils, strformat

import nimblepkg/cli

test "test prompt":
  let token = promptCustom("Personal access token?", "").strip()
  echo "token: " & $token

test "test prompt":
  let resp1 = prompt(dontForcePrompt, "Non-forced prompt example?")
  echo "answer: " & $resp1

test "test overriden prompt":
  let resp2 = prompt(forcePromptYes, "forced prompt (e.g. overriden)")
  assert resp2 == true
  echo "answer: " & $resp2

test "test displays":
  let name = "fakePackage"
  displayWarning(&"Installed package {name} should be renamed  ")
  displayDebug(&"Installed package {name} should be renamed  ")
  displayDetails(&"Installed package {name} should be renamed  ")
  displayError(&"Installed package {name} should be renamed  ")
  displayInfo(&"Installed package {name} should be renamed  ")
  displayHint(&"Installed package {name} should be renamed  ")

test "test display raw":
  display("Msg", "Some message", Hint)
  display("Msg2", "Some message", priority=HighPriority, displayType=Success)
  display("Msg3", "Some message", priority=HighPriority, displayType=Error)

test "test display medium priority":
  setVerbosity(MediumPriority)
  display("Msg", "Some message", Hint)

test "test display colorize":
  setShowColor(false)
  display("Msg33", "Some message", Warning, HighPriority)
  setShowColor(true)
  display("Msg34", "Some message", Warning, HighPriority)

test "test multiline":
  displayInfo("Some message\nwith lots of\nlines")

test "test interactive prompt":
  let resp = promptList(dontForcePrompt, "Select options:", ["alpha", "beta", "gamma"])
  displayInfo(&"Got answer: {resp} ")

Copy link
Collaborator

@dom96 dom96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! The only concern I have is that this might break something on different operating system's or terminal emulator, but I guess we will see :)

src/nimblepkg/cli.nim Outdated Show resolved Hide resolved
src/nimblepkg/cli.nim Outdated Show resolved Hide resolved
@dom96 dom96 merged commit 1339046 into nim-lang:master Dec 4, 2021
CyberTailor pushed a commit to CyberTailor/nimble that referenced this pull request Dec 12, 2021
* menu select add arrows

* Update src/nimblepkg/cli.nim

* Update src/nimblepkg/cli.nim

Co-authored-by: Jaremy J. Creechley <[email protected]>
Co-authored-by: Dominik Picheta <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants