-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Utility functions for writing command-line programs -- -- Utility functions for writing command-line programs including parsing -- of numbers with restrictions and enumerations for command-line -- arguments, verbosity controlled output, escaping shell arguments, exit -- with message. -- -- The package has very light dependencies and is Haskell 98. @package shell-utility @version 0.1 -- | The Exit mechanism is not compositional and thus should not be used in -- larger long-running programs. However, in small command-line utilities -- and especially for signaling errors in command-line arguments it is -- acceptable. -- -- The IO instance is useful for GetOpt and immediate -- exit. The Either instance is useful for eitherReader. module Shell.Utility.Exit class Applicative f => Exit f -- | Also known as die in newer versions of base. exitFailureMsg :: Exit f => String -> f a instance Shell.Utility.Exit.Exit GHC.Types.IO instance Data.String.IsString str => Shell.Utility.Exit.Exit (Data.Either.Either str) module Shell.Utility.GetOpt fmapArgDescr :: (a -> b) -> ArgDescr a -> ArgDescr b fmapOptDescr :: (a -> b) -> OptDescr a -> OptDescr b -- | Both System.Console.GetOpt and Optparse.Applicative do -- not have built-in support for number or enumeration arguments. But -- there is usually a lot to check, e.g. whether numbers are positive, -- not too big, etc. We provide argument parsers here in a way that can -- be used in all command-line parsing libraries. module Shell.Utility.ParseArgument parseNumber :: (Exit m, Read a) => String -> (a -> Bool) -> String -> String -> m a enumMaybe :: (Bounded a, Enum a, Eq str) => (a -> str) -> str -> Maybe a enumeration :: (Bounded a, Enum a) => String -> (a -> String) -> String -> Either String a module Shell.Utility.Quote -- | Put a string in quotes and escape characters as necessary. This allows -- you to construct shell commands such that a shell interprets the -- arguments in the right way. always :: String -> String -- | Like always but encloses in quotes only if necessary. minimal :: String -> String -- | Similar to minimal but starts quoting only as soon as it -- becomes necessary. This is lazy both with respect to quoting and with -- respect to processing. lazy :: String -> String module Shell.Utility.Verbosity data Verbosity -- | We shouldn't print anything unless an error occurs in silent -- mode silent :: Verbosity -- | Print stuff we want to see by default normal :: Verbosity -- | Be more verbose about what's going on verbose :: Verbosity -- | Not only are we verbose ourselves (perhaps even noisier than when -- being verbose), but we tell everything we run to be verbose too deafening :: Verbosity parse :: Exit m => String -> m Verbosity instance GHC.Enum.Bounded Shell.Utility.Verbosity.Verbosity instance GHC.Enum.Enum Shell.Utility.Verbosity.Verbosity instance GHC.Classes.Ord Shell.Utility.Verbosity.Verbosity instance GHC.Classes.Eq Shell.Utility.Verbosity.Verbosity instance GHC.Read.Read Shell.Utility.Verbosity.Verbosity instance GHC.Show.Show Shell.Utility.Verbosity.Verbosity -- | Primitive verbosity controlled logging. module Shell.Utility.Log -- | Non fatal condition that may indicate a problem. -- -- Display on stderr at normal verbosity and above. warn :: Verbosity -> String -> IO () -- | Useful status message. -- -- Display at normal verbosity and above. -- -- This is for the ordinary helpful status messages that users see. Just -- enough information to know that things are working but not floods of -- detail. notice :: Verbosity -> String -> IO () -- | More detail on the operation of some action. -- -- Display at verbose verbosity and above. info :: Verbosity -> String -> IO () -- | Detailed internal debugging information -- -- Display for deafening verbosity. debug :: Verbosity -> String -> IO () wrapWords :: Int -> [String] -> String