Skip to content

Commit 0c80356

Browse files
committed
feat(CLI): use --count when --info is passed
1 parent 7ad8804 commit 0c80356

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/Action/CmdLine.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ search_ = Search
134134
,jsonl = def &= name "jsonl" &= help "Get result as JSONL (JSON Lines)"
135135
,link = def &= help "Give URL's for each result"
136136
,numbers = def &= help "Give counter for each result"
137-
,info = def &= help "Give extended information about the first result"
137+
,info = def &= help "Give extended information about the first n results (set n with --count, default is 1)"
138138
,database = def &= typFile &= help "Name of database to use (use .hoo extension)"
139139
,count = Nothing &= name "n" &= help "Maximum number of results to return (defaults to 10)"
140140
,query = def &= args &= typ "QUERY"

src/Action/Search.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ actionSearch Search{..} = replicateM_ repeat_ $ -- deliberately reopen the datab
5353
if null res then
5454
putStrLn "No results found"
5555
else if info then do
56-
putStr $ targetInfo $ headErr res
56+
mapM_ (putStr . targetInfo)
57+
$ (case count of
58+
Just c -> take c
59+
Nothing -> singleton . headErr) res
5760
else do
5861
let toShow = if numbers && not info then addCounter shown else shown
5962
if | json -> LBS.putStrLn $ JSON.encode $ maybe id take count $ map unHTMLtargetItem res

0 commit comments

Comments
 (0)