eros-client 0.5.0.0 → 0.5.0.1
raw patch · 3 files changed
+11/−156 lines, 3 files
Files
- README.md +1/−142
- eros-client.cabal +3/−6
- src/Main.hs +7/−8
README.md view
@@ -1,144 +1,3 @@ # eros-client -This is a command line interface to the-[eros library](https://github.com/pharpend/eros).--# Usage - v.0.5.0.0--This is a usage guide for version 0.5.0.0. There will be more up-to-date usage-guides as more versions come, hopefully.--To install, run `cabal install eros-client-0.5.0.0`.--The only way to interact with the library, for the time being is through the-client I built, `erosc`. It accepts input in Javascript Object Notation (JSON)-through `stdin`.--Here is the schema for the input:--```json-{- "name": "erosc-input",- "type": "object",- "description": "The schema for the input to erosc.",- "properties": {- "text": {- "type": "string",- "description": "The text you want to be checked against the phraselists.",- "required": true- },- "eros-lists": {- "type": "array",- "description": "The phraselists provided by eros you want \"text\" to be checked against.",- "required": true,- "items": {- "type": "string"- }- },- "options": {- "type": "object",- "description": "Extraneous options for erosc.",- "required": false,- "properties": {- "pretty": {- "type": "boolean",- "description": "Whether to pretty-print the output. Defaults to `true'.",- "required": false- },- "quiet": {- "type": "boolean",- "description": "Suppress output to stdout. Defauts to `false'.",- "required": false- },- "output-files": {- "type": "array",- "description": "A list of output file paths. Will overwrite existing files",- "required": false,- "items": {- "type": "string"- }- }- }- }- }-}-```--That is the up-to-date schema, as of version 0.5.0.0 . It is liable to-change. If the version you downloaded is greater than 0.5.0.0, make sure to-check the schema (it is distributed with the package) to make sure it is up to-date. The schema is located in `res/schemata/erosc-input.json`.--`erosc` will take that input, and send back output in JSON, in accordance with-the schema found in `res/schemata/erosc-output.json`.--```json-{- "name": "erosc-output",- "type": "array",- "description": "The output of erosc.",- "items": {- "type": "object",- "description": "The phraselist name, along with the score for that phraselist.",- "properties": {- "eros-list": {- "type": "string",- "description": "The name of the phraselist corresponding to this object."- },- "score": {- "type": "number",- "description": "The score corresponding to this phraselist."- }- }- }-}-```--## Example--This is the example input from `res/erosc-dummy-inputs/input0.json`.--```json-{- "text": "Fuck you, you fucking fuck! Fucking bitch tits milf sex sluts!",- "eros-lists": [- "gambling",- "pornography"- ]-}-```--Running `erosc < res/erosc-dummy-inputs/input0.json` yields--```json-[- {- "score": 0,- "eros-list": "gambling"- },- {- "score": 11394,- "eros-list": "pornography"- }-]-```--# Contributing--I would love if people would contribute. This client is BSD-licensed, so you can-pretty much do whatever you want with it.--If you have any ideas, don't hesitate to contact me.--## Planned features--I need to add more filtering options, such as phraselist-specific thresholds,-custom phraselists, and, well, just more stuff.--# Contact--The best way to contact me is via IRC. I hang out a lot on `#archlinux` and-`#haskell` on the FreeNode network. My nicks are `l0cust` and `isomorpheous`.--You can also email me at <pharpend2@gmail.com>, although I'm not great at-checking that email address.+Deprecated in favor of [eros-http](https://github.com/pharpend/eros-http).
eros-client.cabal view
@@ -1,10 +1,7 @@ name: eros-client-version: 0.5.0.0-synopsis: A command-line interface to the eros library.-description:- This is a command-line interface to the- <https://github.com/pharpend/eros eros library>.-+version: 0.5.0.1+synopsis: DEPRECATED in favor of eros-http+description: DEPRECATED in favor of eros-http license: BSD3 license-file: LICENSE author: Peter Harpending
src/Main.hs view
@@ -1,7 +1,7 @@ module Main where import Data.Aeson-import qualified Data.ByteString.Lazy as B+import qualified Data.ByteString.Lazy as Bl import qualified Text.Eros.Client as Erosc import qualified Text.Eros.Client.JSON as ErosJson import System.Exit@@ -14,14 +14,14 @@ -- Eventually, I'll add in command line argument parsing, and then we'll -- have a use for the 'EroscOptions' type. main :: IO ()-main = runBtStr =<< B.hGetContents Io.stdin+main = runBtStr =<< Bl.hGetContents Io.stdin -- |attempt to 'eitherDecode' the user input-runBtStr :: B.ByteString -> IO ()+runBtStr :: Bl.ByteString -> IO () runBtStr inputBt = do let eitherJson = (eitherDecode inputBt) :: Either String Erosc.ClientInput case eitherJson of- Left msg -> B.hPutStr Io.stderr (encode msg) >> exitFailure+ Left msg -> Bl.hPutStr Io.stderr (encode msg) >> exitFailure Right ecInput -> runInput ecInput -- |This takes the 'Erosc.ClientInput' thing and processes it.@@ -31,8 +31,7 @@ let conf = Erosc.configuration ipt outfpaths = Erosc.outputFiles conf jsonText = ErosJson.encode result conf- writeOutputs = mapM_ (\fpath -> B.writeFile fpath jsonText) outfpaths+ writeOutputs = mapM_ (\fpath -> Bl.writeFile fpath jsonText) outfpaths if (Erosc.quiet conf)- then B.hPutStr Io.stdout jsonText >> writeOutputs >> exitSuccess- else writeOutputs >> exitSuccess-+ then writeOutputs >> exitSuccess+ else Bl.hPutStr Io.stdout jsonText >> writeOutputs >> exitSuccess