From a20a3adffc043067d3734d4c8d5f71f00c0f50e9 Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Tue, 7 Jul 2015 22:10:31 +0200 Subject: [PATCH] Handle arguments --- src/Main.hs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Main.hs b/src/Main.hs index ffa0acd..3931cc9 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -84,10 +84,23 @@ main :: IO () main = interface >>= (`runApp` search) +-- Program -- + search :: ProgArgs -> IO () search ProgArgs {..} = do - res <- fuzzy "gog.com" <$> getKeychain - pprint res + paths <- if null keychain + 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))