Hello community,
here is the log from the commit of package ghc-optparse-simple for
openSUSE:Factory checked in at 2018-05-30 12:11:13
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/ghc-optparse-simple (Old)
and /work/SRC/openSUSE:Factory/.ghc-optparse-simple.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-optparse-simple"
Wed May 30 12:11:13 2018 rev:4 rq:607850 version:0.1.0
Changes:
--------
--- /work/SRC/openSUSE:Factory/ghc-optparse-simple/ghc-optparse-simple.changes
2017-09-15 22:02:41.373395399 +0200
+++
/work/SRC/openSUSE:Factory/.ghc-optparse-simple.new/ghc-optparse-simple.changes
2018-05-30 12:26:38.355655360 +0200
@@ -1,0 +2,8 @@
+Mon May 14 17:02:11 UTC 2018 - [email protected]
+
+- Update optparse-simple to version 0.1.0.
+ * Migrate from `EitherT` to `ExceptT`
+ [#8](https://github.com/fpco/optparse-simple/issues/8)
+ * Support `--help` on subcommands
+
+-------------------------------------------------------------------
Old:
----
optparse-simple-0.0.3.tar.gz
New:
----
optparse-simple-0.1.0.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ ghc-optparse-simple.spec ++++++
--- /var/tmp/diff_new_pack.5vyaBd/_old 2018-05-30 12:26:39.187626995 +0200
+++ /var/tmp/diff_new_pack.5vyaBd/_new 2018-05-30 12:26:39.191626858 +0200
@@ -1,7 +1,7 @@
#
# spec file for package ghc-optparse-simple
#
-# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -17,8 +17,9 @@
%global pkg_name optparse-simple
+%bcond_with tests
Name: ghc-%{pkg_name}
-Version: 0.0.3
+Version: 0.1.0
Release: 0
Summary: Simple interface to optparse-applicative
License: BSD-3-Clause
@@ -26,12 +27,15 @@
URL: https://hackage.haskell.org/package/%{pkg_name}
Source0:
https://hackage.haskell.org/package/%{pkg_name}-%{version}/%{pkg_name}-%{version}.tar.gz
BuildRequires: ghc-Cabal-devel
-BuildRequires: ghc-either-devel
BuildRequires: ghc-gitrev-devel
BuildRequires: ghc-optparse-applicative-devel
BuildRequires: ghc-rpm-macros
BuildRequires: ghc-template-haskell-devel
BuildRequires: ghc-transformers-devel
+%if %{with tests}
+BuildRequires: ghc-bytestring-devel
+BuildRequires: ghc-directory-devel
+%endif
%description
Simple interface to optparse-applicative.
@@ -57,6 +61,9 @@
%install
%ghc_lib_install
+%check
+%cabal_test
+
%post devel
%ghc_pkg_recache
@@ -64,8 +71,9 @@
%ghc_pkg_recache
%files -f %{name}.files
-%doc LICENSE
+%license LICENSE
%files devel -f %{name}-devel.files
+%doc ChangeLog.md README.md
%changelog
++++++ optparse-simple-0.0.3.tar.gz -> optparse-simple-0.1.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/optparse-simple-0.0.3/ChangeLog.md
new/optparse-simple-0.1.0/ChangeLog.md
--- old/optparse-simple-0.0.3/ChangeLog.md 1970-01-01 01:00:00.000000000
+0100
+++ new/optparse-simple-0.1.0/ChangeLog.md 2017-11-28 10:33:56.000000000
+0100
@@ -0,0 +1,8 @@
+## 0.1.0
+
+* Migrate from `EitherT` to `ExceptT`
+ [#8](https://github.com/fpco/optparse-simple/issues/8)
+
+## 0.0.4
+
+* Support `--help` on subcommands
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/optparse-simple-0.0.3/README.md
new/optparse-simple-0.1.0/README.md
--- old/optparse-simple-0.0.3/README.md 1970-01-01 01:00:00.000000000 +0100
+++ new/optparse-simple-0.1.0/README.md 2017-10-30 14:35:37.000000000 +0100
@@ -0,0 +1,37 @@
+optparse-simple
+=====
+
+Simple interface to optparse-applicative
+
+## Usage
+
+Typical usage with no commands:
+
+``` haskell
+do (opts,()) <-
+ simpleOptions "ver"
+ "header"
+ "desc"
+ (flag () () (long "some-flag"))
+ empty
+ doThings opts
+```
+
+Typical usage with commands:
+
+``` haskell
+do (opts,runCmd) <-
+ simpleOptions "ver"
+ "header"
+ "desc"
+ (pure ()) $
+ do addCommand "delete"
+ "Delete the thing"
+ (const deleteTheThing)
+ (pure ())
+ addCommand "create"
+ "Create a thing"
+ createAThing
+ (strOption (long "hello"))
+ runCmd
+```
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/optparse-simple-0.0.3/optparse-simple.cabal
new/optparse-simple-0.1.0/optparse-simple.cabal
--- old/optparse-simple-0.0.3/optparse-simple.cabal 2015-05-31
15:16:01.000000000 +0200
+++ new/optparse-simple-0.1.0/optparse-simple.cabal 2017-11-28
10:34:07.000000000 +0100
@@ -1,23 +1,59 @@
-name: optparse-simple
-version: 0.0.3
-synopsis: Simple interface to optparse-applicative
-description: Simple interface to optparse-applicative
-license: BSD3
-license-file: LICENSE
-author: FP Complete
-maintainer: [email protected]
-copyright: 2015 FP Complete
-category: Options
-build-type: Simple
-cabal-version: >=1.8
+-- This file has been generated from package.yaml by hpack version 0.20.0.
+--
+-- see: https://github.com/sol/hpack
+--
+-- hash: 5955f8eb9562e24b8a68ecf2cb4c0674a9de7508574a10a44469d8e88bbebdb9
+
+name: optparse-simple
+version: 0.1.0
+synopsis: Simple interface to optparse-applicative
+description: Please see the README at
<https://www.stackage.org/package/optparse-simple>
+category: Options
+homepage: https://github.com/fpco/optparse-simple#readme
+bug-reports: https://github.com/fpco/optparse-simple/issues
+author: FP Complete
+maintainer: [email protected]
+copyright: 2015-2017 FP Complete
+license: BSD3
+license-file: LICENSE
+build-type: Simple
+cabal-version: >= 1.10
+
+extra-source-files:
+ ChangeLog.md
+ README.md
+
+source-repository head
+ type: git
+ location: https://github.com/fpco/optparse-simple
library
- hs-source-dirs: src/
- ghc-options: -Wall -O2
- exposed-modules: Options.Applicative.Simple
- build-depends: base >= 4 && <5
- , template-haskell
- , transformers
- , optparse-applicative
- , gitrev
- , either
+ hs-source-dirs:
+ src/
+ ghc-options: -Wall
+ build-depends:
+ base >=4 && <5
+ , gitrev
+ , optparse-applicative
+ , template-haskell
+ , transformers >=0.4
+ exposed-modules:
+ Options.Applicative.Simple
+ other-modules:
+ Paths_optparse_simple
+ default-language: Haskell2010
+
+test-suite test
+ type: exitcode-stdio-1.0
+ main-is: Main.hs
+ hs-source-dirs:
+ test
+ ghc-options: -Wall
+ build-depends:
+ base
+ , bytestring
+ , directory
+ , optparse-simple
+ other-modules:
+ Paths_optparse_simple
+ default-language: Haskell2010
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/optparse-simple-0.0.3/src/Options/Applicative/Simple.hs
new/optparse-simple-0.1.0/src/Options/Applicative/Simple.hs
--- old/optparse-simple-0.0.3/src/Options/Applicative/Simple.hs 2015-05-31
15:16:01.000000000 +0200
+++ new/optparse-simple-0.1.0/src/Options/Applicative/Simple.hs 2017-11-28
10:33:56.000000000 +0100
@@ -39,7 +39,7 @@
) where
import Control.Monad.Trans.Class (lift)
-import Control.Monad.Trans.Either
+import Control.Monad.Trans.Except
import Control.Monad.Trans.Writer
import Data.Monoid
import Data.Version
@@ -59,7 +59,7 @@
-- ^ program description
-> Parser a
-- ^ global settings
- -> EitherT b (Writer (Mod CommandFields b)) ()
+ -> ExceptT b (Writer (Mod CommandFields b)) ()
-- ^ commands (use 'addCommand')
-> IO (a,b)
simpleOptions versionString h pd globalParser commandParser =
@@ -98,10 +98,10 @@
-> String -- ^ title of command
-> (a -> b) -- ^ constructor to wrap up command in common data type
-> Parser a -- ^ command parser
- -> EitherT b (Writer (Mod CommandFields b)) ()
+ -> ExceptT b (Writer (Mod CommandFields b)) ()
addCommand cmd title constr inner =
lift (tell (command cmd
- (info (constr <$> inner)
+ (info (constr <$> (helper <*> inner))
(progDesc title))))
-- | Add a command that takes sub-commands to the options dispatcher.
@@ -128,9 +128,9 @@
-- ^ command string
-> String
-- ^ title of command
- -> EitherT b (Writer (Mod CommandFields b)) ()
+ -> ExceptT b (Writer (Mod CommandFields b)) ()
-- ^ sub-commands (use 'addCommand')
- -> EitherT b (Writer (Mod CommandFields b)) ()
+ -> ExceptT b (Writer (Mod CommandFields b)) ()
addSubCommands cmd title commandParser =
addCommand cmd
title
@@ -160,7 +160,7 @@
simpleParser
:: Parser a
-- ^ common settings
- -> EitherT b (Writer (Mod CommandFields b)) ()
+ -> ExceptT b (Writer (Mod CommandFields b)) ()
-- ^ commands (use 'addCommand')
-> Parser (a,b)
simpleParser commonParser commandParser =
@@ -171,6 +171,6 @@
help "Show this help text"
config =
(,) <$> commonParser <*>
- case runWriter (runEitherT commandParser) of
+ case runWriter (runExceptT commandParser) of
(Right (),d) -> subparser d
(Left b,_) -> pure b
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/optparse-simple-0.0.3/test/Main.hs
new/optparse-simple-0.1.0/test/Main.hs
--- old/optparse-simple-0.0.3/test/Main.hs 1970-01-01 01:00:00.000000000
+0100
+++ new/optparse-simple-0.1.0/test/Main.hs 2017-10-31 11:26:44.000000000
+0100
@@ -0,0 +1,142 @@
+{-# LANGUAGE RecordWildCards #-}
+{-# LANGUAGE OverloadedStrings #-}
+
+import Options.Applicative.Simple hiding(action)
+import GHC.IO.Handle
+import System.IO
+import System.Environment
+import Control.Exception
+import Control.Monad
+import System.Directory
+import System.Exit
+import Data.ByteString (ByteString)
+import qualified Data.ByteString as BS
+import Data.Monoid ((<>))
+
+
+shouldBe :: (Show a, Eq a) => a -> a -> IO ()
+shouldBe actual expected
+ | expected == actual = return ()
+ | otherwise = do
+ putStrLn $ "expected: " ++ show expected
+ putStrLn $ "actual : " ++ show actual
+ exitFailure
+
+catchReturn :: Exception e => IO e -> IO e
+catchReturn io = io `catch` return
+
+catchExitCode :: IO () -> IO ExitCode
+catchExitCode action = catchReturn $ do
+ action
+ return ExitSuccess
+
+data FakeHandles = FakeHandles
+ { fakeIn :: Handle
+ , fakeOut :: Handle
+ , fakeErr :: Handle
+ , realIn :: Handle
+ , realOut :: Handle
+ , realErr :: Handle
+ }
+
+openFile' :: FilePath -> IO Handle
+openFile' path = do
+ removeIfExists path
+ openFile path ReadWriteMode
+
+removeIfExists :: FilePath -> IO ()
+removeIfExists path = do
+ exists <- doesFileExist path
+ when exists $ do
+ removeFile path
+
+stdinFile :: FilePath
+stdinFile = ".tmp.stdin"
+
+stdoutFile :: FilePath
+stdoutFile = ".tmp.stdout"
+
+stderrFile :: FilePath
+stderrFile = ".tmp.stderr"
+
+beforeFH :: IO FakeHandles
+beforeFH = do
+ realIn <- hDuplicate stdin
+ realOut <- hDuplicate stdout
+ realErr <- hDuplicate stderr
+
+ fakeIn <- openFile stdinFile ReadWriteMode
+ fakeOut <- openFile' stdoutFile
+ fakeErr <- openFile' stderrFile
+
+ hDuplicateTo fakeIn stdin
+ hDuplicateTo fakeOut stdout
+ hDuplicateTo fakeErr stderr
+
+ return FakeHandles{..}
+
+afterFH :: FakeHandles -> IO ()
+afterFH FakeHandles{..} = do
+ hDuplicateTo realIn stdin
+ hDuplicateTo realOut stdout
+ hDuplicateTo realErr stderr
+
+ hClose fakeIn
+ hClose fakeOut
+ hClose fakeErr
+
+withFakeHandles :: IO a -> IO a
+withFakeHandles = bracket beforeFH afterFH . const
+
+withStdIn :: ByteString -> IO ()
+ -> IO (ByteString, ByteString, ExitCode)
+withStdIn inBS action = do
+ BS.writeFile stdinFile inBS
+ withFakeHandles $ do
+ _ <- catchExitCode action
+ hFlush stdout
+ hFlush stderr
+ out <- BS.readFile stdoutFile
+ err <- BS.readFile stderrFile
+
+ removeIfExists stdinFile
+ removeIfExists stdoutFile
+ removeIfExists stderrFile
+
+ return (out, err, ExitSuccess)
+
+
+main :: IO ()
+main = do
+ (out, err, exitCode) <- withStdIn ""
+ $ withArgs ["--version"]
+ $ simpleProg
+ exitCode `shouldBe` ExitSuccess
+ err `shouldBe` ""
+ out `shouldBe` "version\n"
+
+ (out', err', exitCode') <- withStdIn ""
+ $ withArgs ["--summary"]
+ $ summaryProg
+ exitCode' `shouldBe` ExitSuccess
+ err' `shouldBe` ""
+ out' `shouldBe` "A program summary\n"
+
+ return ()
+
+
+simpleProg :: IO ()
+simpleProg = do
+ ((), ()) <- simpleOptions "version" "header" "desc" (pure ()) empty
+ return ()
+
+parserWithSummary :: Parser ()
+parserWithSummary = summaryOption <*> pure () where
+ summaryOption = infoOption "A program summary"
+ $ long "summary"
+ <> help "Show program summary"
+
+summaryProg :: IO ()
+summaryProg = do
+ ((), ()) <- simpleOptions "version" "header" "desc" parserWithSummary empty
+ return ()