Skip to content

Commit 54ac432

Browse files
authored
Merge pull request #9 from purescript-node/bump
Prepare for 2.0 release
2 parents 479edea + 1bc9e87 commit 54ac432

File tree

10 files changed

+153
-93
lines changed

10 files changed

+153
-93
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/.*
22
!/.gitignore
3+
!/.jscsrc
4+
!/.jshintrc
5+
!/.travis.yml
36
/bower_components/
47
/node_modules/
58
/output/
6-
/tmp/

.jscsrc

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"preset": "grunt",
3+
"disallowSpacesInFunctionExpression": null,
4+
"requireSpacesInFunctionExpression": {
5+
"beforeOpeningRoundBrace": true,
6+
"beforeOpeningCurlyBrace": true
7+
},
8+
"disallowSpacesInAnonymousFunctionExpression": null,
9+
"requireSpacesInAnonymousFunctionExpression": {
10+
"beforeOpeningRoundBrace": true,
11+
"beforeOpeningCurlyBrace": true
12+
},
13+
"disallowSpacesInsideObjectBrackets": null,
14+
"requireSpacesInsideObjectBrackets": "all",
15+
"validateQuoteMarks": "\"",
16+
"requireCurlyBraces": null
17+
}

.jshintrc

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"bitwise": true,
3+
"eqeqeq": true,
4+
"forin": true,
5+
"freeze": true,
6+
"funcscope": true,
7+
"futurehostile": true,
8+
"strict": "global",
9+
"latedef": true,
10+
"noarg": true,
11+
"nocomma": true,
12+
"nonew": true,
13+
"notypeof": true,
14+
"singleGroups": true,
15+
"undef": true,
16+
"unused": true,
17+
"eqnull": true,
18+
"predef": ["exports", "require", "process"]
19+
}

.travis.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
language: node_js
2+
dist: trusty
3+
sudo: required
4+
node_js: 6
5+
install:
6+
- npm install -g bower
7+
- npm install
8+
script:
9+
- bower install --production
10+
- npm run -s build
11+
- bower install
12+
- npm test
13+
after_success:
14+
- >-
15+
test $TRAVIS_TAG &&
16+
echo $GITHUB_TOKEN | pulp login &&
17+
echo y | pulp publish --no-push

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# purescript-node-readline
22

3+
[![Latest release](http://img.shields.io/github/release/purescript-node/purescript-node-readline.svg)](https://github.com/purescript-node/purescript-node-readline/releases)
4+
[![Build Status](https://travis-ci.org/purescript-node/purescript-node-readline.svg?branch=master)](https://travis-ci.org/purescript-node/purescript-node-readline)
5+
36
A low-level PureScript interface to the Node `readline` API.
47

58
## Installation

bower.json

+6-11
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
{
22
"name": "purescript-node-readline",
33
"homepage": "https://github.com/purescript-contrib/purescript-node-readline",
4-
"keywords": [
5-
"purescript"
6-
],
74
"repository": {
85
"type": "git",
96
"url": "git://github.com/purescript-node/purescript-node-readline.git"
@@ -14,17 +11,15 @@
1411
"bower_components",
1512
"node_modules",
1613
"output",
17-
"tests",
18-
"tmp",
14+
"test",
1915
"bower.json",
20-
"Gruntfile.js",
2116
"package.json"
2217
],
2318
"dependencies": {
24-
"purescript-console": "^1.0.0",
25-
"purescript-node-streams": "^1.0.0",
26-
"purescript-node-process": "^1.0.0",
27-
"purescript-options": "^1.0.0",
28-
"purescript-foreign": "^1.0.0"
19+
"purescript-console": "^2.0.0",
20+
"purescript-node-streams": "^2.0.0",
21+
"purescript-node-process": "^3.0.0",
22+
"purescript-options": "^2.0.0",
23+
"purescript-foreign": "^3.0.0"
2924
}
3025
}

package.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"private": true,
3+
"scripts": {
4+
"clean": "rimraf output && rimraf .pulp-cache",
5+
"build": "jshint src && jscs src && pulp build --censor-lib --strict",
6+
"test": "pulp build -I test"
7+
},
8+
"devDependencies": {
9+
"jscs": "^3.0.7",
10+
"jshint": "^2.9.4",
11+
"pulp": "^9.0.1",
12+
"purescript-psa": "^0.3.9",
13+
"purescript": "^0.10.1",
14+
"rimraf": "^2.5.4"
15+
}
16+
}

src/Node/ReadLine.js

+23-23
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
/* global exports */
2-
'use strict';
2+
"use strict";
33

44
// module Node.ReadLine
55

6-
exports.createInterfaceImpl = function(options) {
7-
return function() {
8-
var readline = require('readline');
6+
exports.createInterfaceImpl = function (options) {
7+
return function () {
8+
var readline = require("readline");
99
return readline.createInterface({
1010
input: options.input,
1111
output: options.output,
12-
completer: options.completer && function(line) {
12+
completer: options.completer && function (line) {
1313
var res = options.completer(line)();
1414
return [res.completions, res.matched];
1515
},
@@ -19,33 +19,33 @@ exports.createInterfaceImpl = function(options) {
1919
};
2020
};
2121

22-
exports.close = function(readline) {
23-
return function() {
22+
exports.close = function (readline) {
23+
return function () {
2424
readline.close();
2525
};
2626
};
2727

28-
exports.prompt = function(readline) {
29-
return function() {
30-
readline.prompt();
31-
};
28+
exports.prompt = function (readline) {
29+
return function () {
30+
readline.prompt();
31+
};
3232
};
3333

34-
exports.setPrompt = function(prompt) {
35-
return function(length) {
36-
return function(readline) {
37-
return function() {
38-
readline.setPrompt(prompt, length);
39-
};
40-
};
34+
exports.setPrompt = function (prompt) {
35+
return function (length) {
36+
return function (readline) {
37+
return function () {
38+
readline.setPrompt(prompt, length);
39+
};
4140
};
41+
};
4242
};
4343

44-
exports.setLineHandler = function(readline) {
45-
return function(callback) {
46-
return function() {
47-
readline.removeAllListeners('line');
48-
readline.on('line', function(line) {
44+
exports.setLineHandler = function (readline) {
45+
return function (callback) {
46+
return function () {
47+
readline.removeAllListeners("line");
48+
readline.on("line", function (line) {
4949
callback(line)();
5050
});
5151
};

src/Node/ReadLine.purs

+45-53
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@ module Node.ReadLine
2020
) where
2121

2222
import Prelude
23+
2324
import Control.Monad.Eff (Eff)
2425
import Control.Monad.Eff.Console (CONSOLE)
2526
import Control.Monad.Eff.Exception (EXCEPTION)
27+
2628
import Data.Foreign (Foreign)
2729
import Data.Options (Options, Option, (:=), options, opt)
30+
2831
import Node.Process (stdin, stdout)
2932
import Node.Stream (Readable, Writable)
3033

@@ -36,11 +39,10 @@ foreign import data Interface :: *
3639
-- | The effect of interacting with a stream via an `Interface`
3740
foreign import data READLINE :: !
3841

39-
foreign import createInterfaceImpl :: forall eff.
40-
Foreign
41-
-> Eff ( readline :: READLINE
42-
| eff
43-
) Interface
42+
foreign import createInterfaceImpl
43+
:: forall eff
44+
. Foreign
45+
-> Eff ( readline :: READLINE | eff ) Interface
4446

4547
-- | Options passed to `readline`'s `createInterface`
4648
data InterfaceOptions
@@ -61,73 +63,63 @@ historySize = opt "historySize"
6163
-- |
6264
-- | This function takes the partial command as input, and returns a collection of
6365
-- | completions, as well as the matched portion of the input string.
64-
type Completer eff = String -> Eff eff { completions :: Array String
65-
, matched :: String }
66+
type Completer eff
67+
= String
68+
-> Eff eff
69+
{ completions :: Array String
70+
, matched :: String
71+
}
6672

6773
-- | Builds an interface with the specified options.
68-
createInterface :: forall r eff.
69-
Readable r ( readline :: READLINE
70-
| eff
71-
)
72-
-> Options InterfaceOptions
73-
-> Eff ( readline :: READLINE
74-
| eff
75-
) Interface
74+
createInterface
75+
:: forall r eff
76+
. Readable r (readline :: READLINE | eff)
77+
-> Options InterfaceOptions
78+
-> Eff (readline :: READLINE | eff) Interface
7679
createInterface input opts = createInterfaceImpl
7780
$ options $ opts
7881
<> opt "input" := input
7982

8083
-- | Create an interface with the specified completion function.
81-
createConsoleInterface :: forall eff.
82-
Completer ( readline :: READLINE
83-
, console :: CONSOLE
84-
, err :: EXCEPTION
85-
| eff
86-
)
87-
-> Eff ( readline :: READLINE
88-
, console :: CONSOLE
89-
, err :: EXCEPTION
90-
| eff
91-
) Interface
92-
createConsoleInterface compl = createInterface stdin $ output := stdout
93-
<> completer := compl
84+
createConsoleInterface
85+
:: forall eff
86+
. Completer (readline :: READLINE, console :: CONSOLE, err :: EXCEPTION | eff)
87+
-> Eff (readline :: READLINE, console :: CONSOLE, err :: EXCEPTION | eff) Interface
88+
createConsoleInterface compl =
89+
createInterface stdin
90+
$ output := stdout
91+
<> completer := compl
9492

9593
-- | A completion function which offers no completions.
9694
noCompletion :: forall eff. Completer eff
9795
noCompletion s = pure { completions: [], matched: s }
9896

9997
-- | Prompt the user for input on the specified `Interface`.
100-
foreign import prompt :: forall eff.
101-
Interface
102-
-> Eff ( readline :: READLINE
103-
| eff
104-
) Unit
98+
foreign import prompt
99+
:: forall eff
100+
. Interface
101+
-> Eff (readline :: READLINE | eff) Unit
105102

106103
-- | Set the prompt.
107-
foreign import setPrompt :: forall eff.
108-
String
109-
-> Int
110-
-> Interface
111-
-> Eff ( readline :: READLINE
112-
| eff
113-
) Unit
104+
foreign import setPrompt
105+
:: forall eff
106+
. String
107+
-> Int
108+
-> Interface
109+
-> Eff (readline :: READLINE | eff) Unit
114110

115111
-- | Close the specified `Interface`.
116-
foreign import close :: forall eff.
117-
Interface
118-
-> Eff ( readline :: READLINE
119-
| eff
120-
) Unit
112+
foreign import close
113+
:: forall eff
114+
. Interface
115+
-> Eff (readline :: READLINE | eff) Unit
121116

122117
-- | A function which handles each line of input.
123118
type LineHandler eff a = String -> Eff eff a
124119

125120
-- | Set the current line handler function.
126-
foreign import setLineHandler :: forall eff a.
127-
Interface
128-
-> LineHandler ( readline :: READLINE
129-
| eff
130-
) a
131-
-> Eff ( readline :: READLINE
132-
| eff
133-
) Unit
121+
foreign import setLineHandler
122+
:: forall eff a
123+
. Interface
124+
-> LineHandler (readline :: READLINE | eff) a
125+
-> Eff (readline :: READLINE | eff) Unit

test/Main.purs

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
module Test.Main where
22

33
import Prelude
4+
45
import Control.Monad.Eff (Eff)
56
import Control.Monad.Eff.Console (CONSOLE, log)
67
import Control.Monad.Eff.Exception (EXCEPTION)
7-
import Node.ReadLine (READLINE, prompt, close, setLineHandler, setPrompt,
8-
noCompletion, createConsoleInterface)
98

10-
main::forall e.
11-
Eff (readline::READLINE, console::CONSOLE, err :: EXCEPTION | e) Unit
9+
import Node.ReadLine (READLINE, prompt, close, setLineHandler, setPrompt, noCompletion, createConsoleInterface)
10+
11+
main :: forall eff. Eff (readline::READLINE, console::CONSOLE, err :: EXCEPTION | eff) Unit
1212
main = do
1313
interface <- createConsoleInterface noCompletion
14-
1514
setPrompt "> " 2 interface
1615
prompt interface
1716
setLineHandler interface $ \s ->

0 commit comments

Comments
 (0)