diff --git a/CHANGELOG.md b/CHANGELOG.md index 2bb26ec..de35f1f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,3 +27,7 @@ ## 2.8.0.436 -- 2019-11-13 * Added a base-compat constraint so that regex always compiles and added tested-with to the cabal file. Changed the stack resolver to lts-14.14. Small improvement in the documentation. + +## 2.8.0.437 -- 2020-03-23 + +* Added the --wait-on-stdin (-W) option to resolve issue #1. Removed the now unnecessary base-compat constraint given regex-1.0.*-r1. Removed extra 'import Crypto.Hash' line in UtilsUnsafe.hs. Corrected some small documentation issues. Updated the scidb-hquery.cabal and stack.yaml files. These changes did not change the primitive API of hquery. Tested lightly with SciDB 19.11 community edition. diff --git a/README.md b/README.md index f933223..51fed19 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ NAME hquery - Haskell query for SciDB via shim SYNOPSIS - hquery [-V n] [-t hstfile] [-c certstore] [-n] + hquery [-V n] [-W] [-t hstfile] [-c certstore] [-n] [-r http[s]] [-i host] [-p port] [-a true|false] [-e true|false] [-o fmt] [-b num] [-d|-s] [-u usr] [-w pw] @@ -243,6 +243,10 @@ OPTIONS -V1 Shows some HTTP exceptions and trace information (--verbose=1). -V2 Shows additional URL information (--verbose=2). + -W Wait on stdin (--wait-on-stdin). In some cases, hquery can + determine that stdin is ready in which case it is consumed. + The -W option guarantees that hquery waits on stdin. + OPERANDS SciDB AFL queries. @@ -250,11 +254,11 @@ USAGE NOTES The development of the utility hquery began with SciDB community edition 13 and continued with 14, 15, 16, 18, and 19. - This version of hquery has been lightly tested with ghc - version 8.2.2 and 8.6.5 and SciDB 18.1 and 19.3 community edition. + This version of hquery has been lightly tested with ghc version + 8.2.2 and 8.6.5 and SciDB 18.1, 19.3 and 19.11 community edition. Currently the command hquery has never been tested on a SciDB - enterprise edition, and thus it is not known if SciDB - authorization (-s) or prefix (-x) actually works. + enterprise edition, and thus it is not known if SciDB authorization + (-s) or a prefix (-x) actually works. EXAMPLES To list all currently defined arrays with SciDB authorization @@ -297,6 +301,11 @@ EXAMPLES hquery -i coordinator -b 0 -x "set_namespace('sensor_data');" \ "list('arrays');" + To find and project the arrays A, B, C and D to be removed, use + + hquery -otsv "project(apply(filter(list('arrays'),regex(name,'A|B|C|D')), + remove,'remove('+name+');'),remove);" | hquery -W + To display a synopsis of this internal manual page, use hquery -y diff --git a/scidb-hquery.cabal b/scidb-hquery.cabal index 32ee91f..c3551f5 100644 --- a/scidb-hquery.cabal +++ b/scidb-hquery.cabal @@ -1,11 +1,12 @@ cabal-version: 2.4 name: scidb-hquery -version: 2.8.0.436 +version: 2.8.0.437 license: GPL-3.0-only license-file: LICENSE copyright: All rights reserved 2014-19(c). maintainer: marcus@gabriel.name author: Marcus D. Gabriel +tested-with: ghc ==8.6.5 homepage: https://github.com/mdgabriel/scidb-hquery.git bug-reports: https://github.com/mdgabriel/scidb-hquery/issues synopsis: Haskell query for SciDB via shim @@ -14,19 +15,18 @@ description: interacitve session with a SciDB server using SciDB's shim protocol at host localhost and port 8080. See the [homepage](https://github.com/mdgabriel/scidb-hquery.git), "hquery -m", and [www.paradigm4.com](http://www.paradigm4.com) for more infomation. - Note that scidb-hquery builds with cabal v2-build and stack resolver lts-14.14. + Note that scidb-hquery builds with cabal v2-build and stack resolver lts-14.27. category: program, client, database, library build-type: Custom extra-source-files: CHANGELOG.md README.md src/SciDbAFL.cf -tested-with: GHC==8.6.5 source-repository head type: git location: https://github.com/mdgabriel/scidb-hquery.git - tag: 2.8.0.436 + tag: 2.8.0.437 custom-setup setup-depends: base >=4.12.0.0 && <4.13, @@ -69,19 +69,17 @@ library cryptonite >=0.25 && <0.27, data-default-class >=0.1.2.0 && <0.2, exceptions >=0.10.2 && <0.11, - haskeline >=0.7.5.0 && <0.8, + haskeline >=0.7.5.0 && <0.9, hostname-validate >=1.0.0 && <1.1, http-client >=0.5.14 && <0.7, http-client-tls >=0.3.5.3 && <0.4, http-conduit >=2.3.7.1 && <2.4, http-types >=0.12.3 && <0.13, - memory >=0.14.18 && <0.15, + memory >=0.14.18 && <0.16, mtl >=2.2.2 && <2.3, network >=2.8.0.1 && <3.2, process >=1.6.5.0 && <1.7, - -- base-compat constraint needed so that regex continues to compile - base-compat >=0.6 && <0.11, - regex >=1.0.2.0 && <1.1, + regex >=1.0.2.0 && <1.2, safe >=0.3.17 && <0.4, split >=0.2.3.3 && <0.3, terminal-size >=0.3.2.1 && <0.4, @@ -125,19 +123,17 @@ executable hquery directory >=1.3.3.0 && <1.4, exceptions >=0.10.2 && <0.11, filepath >=1.4.2.1 && <1.5, - haskeline >=0.7.5.0 && <0.8, + haskeline >=0.7.5.0 && <0.9, hostname-validate >=1.0.0 && <1.1, http-client >=0.5.14 && <0.7, http-client-tls >=0.3.5.3 && <0.4, http-conduit >=2.3.7.1 && <2.4, http-types >=0.12.3 && <0.13, - memory >=0.14.18 && <0.15, + memory >=0.14.18 && <0.16, mtl >=2.2.2 && <2.3, network >=2.8.0.1 && <3.2, process >=1.6.5.0 && <1.7, - -- base-compat constraint needed so that regex continues to compile - base-compat >=0.6 && <0.11, - regex >=1.0.2.0 && <1.1, + regex >=1.0.2.0 && <1.2, safe >=0.3.17 && <0.4, split >=0.2.3.3 && <0.3, terminal-size >=0.3.2.1 && <0.4, diff --git a/src/Environment.hs b/src/Environment.hs index 1fb18fa..8f8dc6b 100644 --- a/src/Environment.hs +++ b/src/Environment.hs @@ -46,6 +46,7 @@ data Environment = , password :: String -- ^ Password for username , operands :: [String] -- ^ List of queries , file :: String -- ^ File of queries + , waitOnStdIn :: Bool -- ^ Wait on stdin , help :: Bool -- ^ @-h@, display help summary , license :: Bool -- ^ @-l@, display license terms , manual :: Bool -- ^ @-m@, display internal man page @@ -86,6 +87,7 @@ defaultEnv = , password = "" -- Password needed for -d or -s option , operands = [] -- No operands by default, i.e., interactive mode , file = "" -- No file of queries by default + , waitOnStdIn = False -- Wait on stdin , help = False -- False or off by default , license = False -- False or off by default , manual = False -- False or off by default diff --git a/src/HQuery.hs b/src/HQuery.hs index 67b86fb..88ebb9e 100644 --- a/src/HQuery.hs +++ b/src/HQuery.hs @@ -74,7 +74,7 @@ import Environment (Environment(certStore,defFetch,de ,defReadingLines,defPrefix,digestAuth ,digestHeaders,file,history,host,insecure ,operands,password,port,protocol,sciDbVersion - ,scidbAuth,username,verbose) + ,scidbAuth,username,verbose,waitOnStdIn) ,defaultEnv,maybePort,Verbosity(..)) import ErrM (Err(..)) import Interpreter (Results(..),interpret) @@ -201,7 +201,7 @@ maybeSetDigestAuth r = -- 'defNumber' lines (23 by default); an exception occurs when -- attempting to fetch no returned lines. If fetch is false, do not -- fetch any lines. For exmample, fetch should be set to false for --- store, create and load. See 'interpretOperatorId' in +-- store, create and load. See 'interpretFuncId' in -- Interpreter.hs for details. unsafeRunQuery :: Environment -> String -> IO String @@ -240,11 +240,11 @@ hquery e = withSocketsDo (runReaderT (evalStateT _hquery defaultParam) e) do initParam e <- ask r <- liftIO $ hReady stdin - if null (operands e) && null (file e) && not r + if null (operands e) && null (file e) && not (waitOnStdIn e) && not r then do liftIO $ putStrLn ("SciDB version "++sciDbVersion e) executeQuery DontExitOnBad "list('instances');" iQuery - else do c <- liftIO $ if r then getContents else return "" + else do c <- liftIO $ if r || waitOnStdIn e then getContents else return "" f <- liftIO $ (if null (file e) then return else readFile) (file e) let a = intercalate "\n" ("":(nolines <$> operands e)) executeQuery ExitOnBad (c ++ f ++ a) diff --git a/src/Main.hs b/src/Main.hs index 25149c2..9148474 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -68,7 +68,7 @@ for 'hquery': > hquery - Haskell query for SciDB via shim > > SYNOPSIS -> hquery [-V n] [-t hstfile] [-c certstore] [-n] +> hquery [-V n] [-W] [-t hstfile] [-c certstore] [-n] > [-r http[s]] [-i host] [-p port] [-a true|false] > [-e true|false] [-o fmt] [-b num] [-d|-s] [-u usr] [-w pw] > [-f qyfile] [query...] @@ -276,6 +276,10 @@ for 'hquery': > -V1 Shows some HTTP exceptions and trace information (--verbose=1). > -V2 Shows additional URL information (--verbose=2). > +> -W Wait on stdin (--wait-on-stdin). In some cases, hquery can +> determine that stdin is ready in which case it is consumed. +> The -W option guarantees that hquery waits on stdin. +> > OPERANDS > SciDB AFL queries. > @@ -283,11 +287,11 @@ for 'hquery': > The development of the utility hquery began with SciDB community > edition 13 and continued with 14, 15, 16, 18, and 19. > -> This version of hquery has been lightly tested with ghc -> version 8.2.2 and 8.6.5 and SciDB 18.1 and 19.3 community edition. +> This version of hquery has been lightly tested with ghc version +> 8.2.2 and 8.6.5 and SciDB 18.1, 19.3 and 19.11 community edition. > Currently the command hquery has never been tested on a SciDB -> enterprise > edition, and thus it is not known if SciDB -> authorization (-s) or prefix (-x) actually works. +> enterprise edition, and thus it is not known if SciDB authorization +> (-s) or a prefix (-x) actually works. > > EXAMPLES > To list all currently defined arrays with SciDB authorization required, @@ -330,6 +334,11 @@ for 'hquery': > hquery -i coordinator -b 0 -x "set_namespace('sensor_data');" \ > "list('arrays');" > +> To find and project the arrays A, B, C and D to be removed, use +> +> hquery -otsv "project(apply(filter(list('arrays'),regex(name,'A|B|C|D')), +> remove,'remove('+name+');'),remove);" | hquery -W +> > To display a synopsis of this internal manual page, use > > hquery -y @@ -455,9 +464,9 @@ config = Config { argOrder = RequireOrder, -- Update revision number: toggle case - release = "2.8.0.436", + release = "2.8.0.437", flagsOps = " [[-g|-h|-l|-m|-v|-y] |"++ - "\n [-V n] [-t hstfile] [-c certstore] [-n]"++ + "\n [-V n] [-W] [-t hstfile] [-c certstore] [-n]"++ "\n [-r http[s]] [-i host] [-p port] [-a true|false]"++ "\n [-e true|false] [-o fmt] [-b num] [-d|-s] [-u usr] [-w pw]"++ "\n [-f qyfile] [query...]"++ @@ -475,7 +484,7 @@ Flags set as a function of the command line options supplied. -} data Flag = Help | License | Manual | Synopsis | Version | Verbose Verbosity | Host String | Port String | Protocol String | File FilePath - | History String | Username String | Password String + | History String | Username String | Password String | WaitOnStdIn | Fetch String | Format String | Number String | VersionSciDb | DigestAuth | SciDbAuth | CertStore String | Insecure | ReadingLines String | Prefix String @@ -508,6 +517,7 @@ options = , Option "y" ["synopsis"] (NoArg Synopsis) "Help synopsis." , Option "x" ["prefix"] (ReqArg Prefix "PREFIX") "Prefix to execute before a query by shim." , Option "V" ["verbose"] (OptArg inpver "012") "Verbose information to stderr." + , Option "W" ["wait-on-stdin"] (NoArg WaitOnStdIn) "Wait on stdin." ] where inpver :: Maybe String -> Flag inpver ms = Verbose $ case (fromMaybe (-1) . readMay . fromMaybe "1") ms of @@ -546,6 +556,7 @@ updateEnvField env opt = Version -> env{version = True} VersionSciDb->env{versionSciDb= True} Verbose v -> env{verbose = v} + WaitOnStdIn-> env{waitOnStdIn = True} where tOrF s = case fmap toLower s of "true" -> Just True "false" -> Just False diff --git a/src/Manual.hs b/src/Manual.hs index 0891036..3f93877 100644 --- a/src/Manual.hs +++ b/src/Manual.hs @@ -19,7 +19,7 @@ internalManual = " hquery - Haskell query for SciDB via shim\n"++ "\n"++ "SYNOPSIS\n"++ - " hquery [-V n] [-t hstfile] [-c certstore] [-n]\n"++ + " hquery [-V n] [-W] [-t hstfile] [-c certstore] [-n]\n"++ " [-r http[s]] [-i host] [-p port] [-a true|false]\n"++ " [-e true|false] [-o fmt] [-b num] [-d|-s] [-u usr] [-w pw]\n"++ " [-f qyfile] [query...]\n"++ @@ -227,6 +227,10 @@ internalManual = " -V1 Shows some HTTP exceptions and trace information (--verbose=1).\n"++ " -V2 Shows additional URL information (--verbose=2).\n"++ "\n"++ + " -W Wait on stdin (--wait-on-stdin). In some cases, hquery can\n"++ + " determine that stdin is ready in which case it is consumed.\n"++ + " The -W option guarantees that hquery waits on stdin.\n"++ + "\n"++ "OPERANDS\n"++ " SciDB AFL queries.\n"++ "\n"++ @@ -234,11 +238,11 @@ internalManual = " The development of the utility hquery began with SciDB community\n"++ " edition 13 and continued with 14, 15, 16, 18, and 19.\n"++ "\n"++ - " This version of hquery has been lightly tested with ghc\n"++ - " version 8.2.2 and 8.6.5 and SciDB 18.1 and 19.3 community edition.\n"++ - " Currently the command hquery has never been tested on a SciDB\n"++ - " enterprise edition, and thus it is not known if SciDB\n"++ - " authorization (-s) or prefix (-x) actually works.\n"++ + " This version of hquery has been lightly tested with ghc version\n"++ + " 8.2.2 and 8.6.5 and SciDB 18.1, 19.3 and 19.11 community edition.\n"++ + " Currently the command hquery has never been tested on a SciDB\n"++ + " enterprise edition, and thus it is not known if SciDB authorization\n"++ + " (-s) or a prefix (-x) actually works.\n"++ "\n"++ "EXAMPLES\n"++ " To list all currently defined arrays with SciDB authorization required,\n"++ @@ -281,6 +285,11 @@ internalManual = " hquery -i coordinator -b 0 -x \"set_namespace('sensor_data');\" \\\n"++ " \"list('arrays');\"\n"++ "\n"++ + " To find and project the arrays A, B, C and D to be removed, use\n"++ + "\n"++ + " hquery -otsv \"project(apply(filter(list('arrays'),regex(name,'A|B|C|D')),\n"++ + " remove,'remove('+name+');'),remove);\" | hquery -W\n"++ + "\n"++ " To display a synopsis of this internal manual page, use\n"++ "\n"++ " hquery -y\n"++ diff --git a/src/UtilsUnsafe.hs b/src/UtilsUnsafe.hs index 553db4d..3105efb 100644 --- a/src/UtilsUnsafe.hs +++ b/src/UtilsUnsafe.hs @@ -15,7 +15,6 @@ import qualified Data.ByteString as B (empty) import qualified Data.ByteString.Char8 as C (pack) import Control.Monad (unless) -import Crypto.Hash --() import Data.Char (toLower) import Data.Default.Class (def) import Data.Maybe (fromMaybe,fromJust,isNothing) diff --git a/stack.yaml b/stack.yaml index 12f1e25..e8cafd7 100644 --- a/stack.yaml +++ b/stack.yaml @@ -17,7 +17,7 @@ # # resolver: ./custom-snapshot.yaml # resolver: https://example.com/snapshots/2018-01-01.yaml -resolver: lts-14.14 +resolver: lts-14.27 # User packages to be built. # Various formats can be used as shown in the example below. @@ -25,20 +25,23 @@ resolver: lts-14.14 # packages: # - some-directory # - https://example.com/foo/bar/baz-0.0.2.tar.gz -# - location: -# git: https://github.com/commercialhaskell/stack.git -# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a -# - location: https://github.com/commercialhaskell/stack/commit/e7b331f14bcffb8367cd58fbfc8b40ec7642100a -# subdirs: -# - auto-update -# - wai +# subdirs: +# - auto-update +# - wai packages: - . -# Dependency packages to be pulled from upstream that are not in the resolver -# using the same syntax as the packages field. -# (e.g., acme-missiles-0.3) +# Dependency packages to be pulled from upstream that are not in the resolver. +# These entries can reference officially published versions as well as +# forks / in-progress versions pinned to a git hash. For example: +# +# extra-deps: +# - acme-missiles-0.3 +# - git: https://github.com/commercialhaskell/stack.git +# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a +# # extra-deps: [] -extra-deps: ["BNFC-2.8.2@sha256:dae284c327ed39c28722479081c0bd4a686e0d2bd1dff790b350b8a1742f4036"] +extra-deps: +- BNFC-2.8.3@sha256:606b82fb80afd92ac5059ec76ea96992b23ae30196c511f1bb8e92addbf2edfe,10943 # Override default flag values for local packages and extra-deps # flags: {} @@ -51,7 +54,7 @@ extra-deps: ["BNFC-2.8.2@sha256:dae284c327ed39c28722479081c0bd4a686e0d2bd1dff790 # # Require a specific version of stack, using version ranges # require-stack-version: -any # Default -# require-stack-version: ">=1.9" +# require-stack-version: ">=2.1" # # Override the architecture used by stack, especially useful on Windows # arch: i386