From f183de5611ecdd02f8bef11aec204ee6dee8ae6d Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Tue, 20 Mar 2012 11:48:08 +0100 Subject: [PATCH] Allow hail to read data from stdin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch makes hail treat '-' as denoting stdin, per the usual Unix convention. This will help with testing. Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: RenΓ© Nussbaumer <rn@google.com> --- htools/Ganeti/HTools/IAlloc.hs | 4 +++- man/hail.rst | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/htools/Ganeti/HTools/IAlloc.hs b/htools/Ganeti/HTools/IAlloc.hs index 7a9e01180..3142755a1 100644 --- a/htools/Ganeti/HTools/IAlloc.hs +++ b/htools/Ganeti/HTools/IAlloc.hs @@ -347,7 +347,9 @@ processRequest request = -- | Reads the request from the data file(s). readRequest :: FilePath -> IO Request readRequest fp = do - input_data <- readFile fp + input_data <- case fp of + "-" -> getContents + _ -> readFile fp case parseData input_data of Bad err -> do hPutStrLn stderr $ "Error: " ++ err diff --git a/man/hail.rst b/man/hail.rst index f3e4403b1..f426cfa55 100644 --- a/man/hail.rst +++ b/man/hail.rst @@ -24,6 +24,9 @@ state and the request details, and output (on stdout) a JSON-formatted response. In case of critical failures, the error message is printed on stderr and the exit code is changed to show failure. +If the input file name is ``-`` (a single minus sign), then the request +data will be read from *stdin*. + ALGORITHM ~~~~~~~~~ -- GitLab