turtle 1.5.16 → 1.5.17
raw patch · 5 files changed
+86/−3 lines, 5 filesdep ~directory
Dependency ranges changed: directory
Files
- CHANGELOG.md +6/−0
- src/Turtle/Options.hs +40/−0
- src/Turtle/Prelude.hs +9/−0
- src/Turtle/Tutorial.hs +29/−0
- turtle.cabal +2/−3
CHANGELOG.md view
@@ -1,3 +1,9 @@+1.5.17++* Add `optionsExt`: Extended version of `options` with header, footer,+ porgram-description and version information in `--help` flag+* Add `readlink`+ 1.5.16 * Add `cptreeL`
src/Turtle/Options.hs view
@@ -71,6 +71,7 @@ , subcommand , subcommandGroup , options+ , optionsExt ) where @@ -107,6 +108,30 @@ prefs = Opts.showHelpOnError #endif +{-| Parse the given options from the command line and add additional information++ Extended version of @options@ with program version header and footer information+-}+optionsExt :: MonadIO io => Header -> Footer -> Description -> Version -> Parser a -> io a+optionsExt header footer desc version parser = liftIO+ $ Opts.customExecParser (Opts.prefs prefs)+ $ Opts.info (Opts.helper <*> versionOption <*> parser)+ (Opts.headerDoc (Just (getHeader header)) <>+ Opts.footerDoc (Just (getFooter footer)) <>+ Opts.progDescDoc (Just (getDescription desc)))+ where+ versionOption =+ Opts.infoOption+ (Text.unpack version)+ (Opts.long "version" <> Opts.help "Show version")+ prefs :: Opts.PrefsMod+#if MIN_VERSION_optparse_applicative(0,13,0)+ prefs = Opts.showHelpOnError <> Opts.showHelpOnEmpty+#else+ prefs = Opts.showHelpOnError+#endif++ {-| The name of a command-line argument This is used to infer the long name and metavariable for the command line@@ -135,6 +160,21 @@ newtype Description = Description { getDescription :: Doc } deriving (IsString) +{-| Header of the program++ This description will appear in the header of the @--help@ output+-}+newtype Header = Header { getHeader :: Doc }+ deriving (IsString)+{-| Footer of the program++ This description will appear in the footer of the @--help@ output+-}+newtype Footer = Fotter { getFooter :: Doc }+ deriving (IsString)++-- | Program Version+type Version = Text {-| A helpful message explaining what a flag does This will appear in the @--help@ output
src/Turtle/Prelude.hs view
@@ -121,6 +121,7 @@ , cd , pwd , home+ , readlink , realpath , mv , mkdir@@ -942,6 +943,14 @@ -- | Get the home directory home :: MonadIO io => io FilePath home = liftIO Filesystem.getHomeDirectory++-- | Get the path pointed to by a symlink+readlink :: MonadIO io => FilePath -> io FilePath+readlink =+ fmap Filesystem.decodeString+ . liftIO+ . System.Directory.getSymbolicLinkTarget+ . Filesystem.encodeString -- | Canonicalize a path realpath :: MonadIO io => FilePath -> io FilePath
src/Turtle/Tutorial.hs view
@@ -116,6 +116,9 @@ -- * Conclusion -- $conclusion + -- * Nix scripts+ -- $nix+ -- * FAQ -- $faq ) where@@ -1796,6 +1799,31 @@ -- still benefit from adding more utilities for better parity with the Unix -- ecosystem. Pull requests to add new utilities are highly welcome! +-- $nix+--+-- You can also turn `turtle` scripts into runnable scripts using Nix, like+-- this:+--+-- > #! /usr/bin/env nix-shell+-- > #! nix-shell -i runghc --packages "ghc.withPackages (x: [ x.turtle ])"+-- > +-- > {-# LANGUAGE OverloadedStrings #-}+-- > +-- > import Turtle+-- > +-- > main = echo "Hello, world!"+--+-- ... or create an auto-reloading script like this:+--+-- > #! /usr/bin/env nix-shell+-- > #! nix-shell -i "ghcid -T main" --packages ghcid "ghc.withPackages (x: [ x.turtle ])"+-- > +-- > {-# LANGUAGE OverloadedStrings #-}+-- > +-- > import Turtle+-- > +-- > main = echo "Hello, world!"+ -- $faq -- -- These are the most frequently asked questions from new users:@@ -1853,3 +1881,4 @@ -- like this: -- -- > Turtle.system (System.Process.proc "/bin/sh" []) empty+
turtle.cabal view
@@ -1,5 +1,5 @@ Name: turtle-Version: 1.5.16+Version: 1.5.17 Cabal-Version: >=1.10 Build-Type: Simple License: BSD3@@ -7,7 +7,6 @@ Copyright: 2015 Gabriel Gonzalez Author: Gabriel Gonzalez Maintainer: Gabriel439@gmail.com-Tested-With: GHC == 7.10.2, GHC == 8.0.1 Bug-Reports: https://github.com/Gabriel439/Haskell-Turtle-Library/issues Synopsis: Shell programming, Haskell-style Description: @turtle@ is a reimplementation of the Unix command line environment@@ -55,7 +54,7 @@ bytestring >= 0.9.1.8 && < 0.11, clock >= 0.4.1.2 && < 0.9 , containers >= 0.5.0.0 && < 0.7 ,- directory >= 1.0.7 && < 1.4 ,+ directory >= 1.3.1.0 && < 1.4 , exceptions >= 0.4 && < 0.11, foldl >= 1.1 && < 1.5 , hostname < 1.1 ,