Skip to content

Commit

Permalink
Added --limit to buy command
Browse files Browse the repository at this point in the history
  • Loading branch information
kfsone committed Nov 20, 2014
1 parent 16ec9d0 commit 3ec13d1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions commands/buy_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
metavar='N.NN',
type=float,
),
ParseArgument('--limit',
help='Maximum number of results to list.',
default=None,
type=int,
),
MutuallyExclusiveGroup(
ParseArgument('--price-sort', '-P',
help='(When using --near) Sort by price not distance',
Expand Down Expand Up @@ -129,6 +134,10 @@ def run(results, cmdenv, tdb):
results.summary.sort = "Dist"
results.rows.sort(key=lambda result: result.dist)

limit = cmdenv.limit or 0
if limit > 0:
results.rows = results.rows[:limit]

return results

#######################################################################
Expand Down

0 comments on commit 3ec13d1

Please sign in to comment.