Handle arguments

This commit is contained in:
rnhmjoj 2015-07-07 22:10:31 +02:00
parent c7a625a090
commit a20a3adffc

View File

@ -84,10 +84,23 @@ main :: IO ()
main = interface >>= (`runApp` search) main = interface >>= (`runApp` search)
-- Program --
search :: ProgArgs -> IO () search :: ProgArgs -> IO ()
search ProgArgs {..} = do search ProgArgs {..} = do
res <- fuzzy "gog.com" <$> getKeychain paths <- if null keychain
pprint res then keychainList
else return [keychain]
items <- getKeychain paths
let select = if resultsLimit == 0
then id
else take resultsLimit
let res = if null exactMatches
then select (fuzzy searchTerm items)
else select (byAttrib (Left exactMatches, Str searchTerm) items)
if contentOnly
then mapM_ print (map content res)
else pprint res
when (not noClipboard) (sendClipboard (content $ head res)) when (not noClipboard) (sendClipboard (content $ head res))