Skip to content

Prep repo for breaking changes #31

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

Merged
merged 2 commits into from
Jul 20, 2023
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
12 changes: 9 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: purescript-contrib/setup-purescript@main
with:
purescript: "unstable"
purs-tidy: "latest"

- uses: actions/setup-node@v2
- uses: actions/setup-node@v3
with:
node-version: "14"
node-version: "lts/*"

- name: Install dependencies
run: |
Expand All @@ -33,3 +34,8 @@ jobs:
run: |
bower install
npm run-script test --if-present

- name: Check Formatting
if: runner.os == 'Linux'
run: |
npx purs-tidy check src
17 changes: 9 additions & 8 deletions src/Node/ReadLine.purs
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ historySize = opt "historySize"
-- |
-- | This function takes the partial command as input, and returns a collection of
-- | completions, as well as the matched portion of the input string.
type Completer
= String
type Completer =
String
-> Effect
{ completions :: Array String
, matched :: String
}
{ completions :: Array String
, matched :: String
}

-- | Builds an interface with the specified options.
createInterface
Expand All @@ -69,15 +69,16 @@ createInterface
-> Options InterfaceOptions
-> Effect Interface
createInterface input opts = createInterfaceImpl
$ options $ opts
<> opt "input" := input
$ options
$ opts
<> opt "input" := input

-- | Create an interface with the specified completion function.
createConsoleInterface :: Completer -> Effect Interface
createConsoleInterface compl =
createInterface stdin
$ output := stdout
<> completer := compl
<> completer := compl

-- | A completion function which offers no completions.
noCompletion :: Completer
Expand Down
11 changes: 5 additions & 6 deletions test/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@ import Prelude
import Effect (Effect)
import Effect.Console (log)

import Node.ReadLine (prompt, close, setLineHandler, setPrompt, noCompletion, createConsoleInterface)
import Node.ReadLine (prompt, close, setLineHandler, setPrompt, noCompletion, createConsoleInterface)

main :: Effect Unit
main = do
interface <- createConsoleInterface noCompletion
setPrompt "> " interface
prompt interface
interface # setLineHandler \s ->
if s == "quit"
then close interface
else do
log $ "You typed: " <> s
prompt interface
if s == "quit" then close interface
else do
log $ "You typed: " <> s
prompt interface