{-|
This Rpm module currently only provides @rpmspec@.
-}

module SimpleCmd.Rpm (
  rpmspec
  ) where

import SimpleCmd (cmdLines)

-- | @rpmspec args mqueryformat specfile@ runs rpmspec query on file with optional args (a newline is appended to any queryformat)
--
-- @since 0.1.1
rpmspec :: [String] -> Maybe String -> FilePath -> IO [String]
rpmspec :: [String] -> Maybe String -> String -> IO [String]
rpmspec [String]
args Maybe String
mqf String
spec = do
  let qf :: [String]
qf = [String] -> (String -> [String]) -> Maybe String -> [String]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\ String
q -> [String
"--queryformat", String
q String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"\n"]) Maybe String
mqf
  String -> [String] -> IO [String]
cmdLines String
"rpmspec" ([String
"-q"] [String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ [String]
args [String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ [String]
qf [String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ [String
spec])