Skip to content

Commit

Permalink
Normalized --avoid for places
Browse files Browse the repository at this point in the history
  • Loading branch information
kfsone committed May 4, 2015
1 parent 846b68f commit 95b3dbd
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 23 deletions.
9 changes: 1 addition & 8 deletions commands/buy_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,7 @@
default=None,
type=int,
),
ParseArgument(
'--avoid',
help=(
"Don't list results for specified systems/stations.\n"
"Names can be one-per --avoid or comma separated."
),
action='append',
),
AvoidPlacesArgument(),
PadSizeArgument(),
BlackMarketSwitch(),
MutuallyExclusiveGroup(
Expand Down
9 changes: 2 additions & 7 deletions commands/nav_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,7 @@
metavar='N.NN',
type=float,
),
ParseArgument('--avoid',
help='Exclude a system from the route. If you specify a station, '
'the system that station is in will be avoided instead.',
action='append',
default=[],
),
AvoidPlacesArgument(),
ParseArgument('--via',
help='Require specified systems/stations to be en-route (in order).',
action='append',
Expand Down Expand Up @@ -232,4 +227,4 @@ def render(results, cmdenv, tdb):
for stnRow in row.stations:
print(stnRowFmt.format(stnRow))

return results
return results
13 changes: 13 additions & 0 deletions commands/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,19 @@ def __init__(self):
}


class AvoidPlacesArgument(ParseArgument):
def __init__(self):
self.args = ['--avoid']
self.kwargs = {
'action': 'append',
'help': (
"Don't list results for the specified systems or stations.\n"
"Names can be one-per '--avoid' or comma separated, e.g. "
"'--avoid a,b,c' or '--avoid a,b --avoid c'"
),
}


class SwitchArgument(ParseArgument):
def __init__(self, help=None):
if isinstance(self.switches, (tuple, list)):
Expand Down
9 changes: 1 addition & 8 deletions commands/sell_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,7 @@
metavar='N.NN',
type=float,
),
ParseArgument(
'--avoid',
help=(
"Don't list results for specified systems/stations.\n"
"Names can be one-per --avoid or comma separated."
),
action='append',
),
AvoidPlacesArgument(),
PadSizeArgument(),
BlackMarketSwitch(),
ParseArgument('--limit',
Expand Down

0 comments on commit 95b3dbd

Please sign in to comment.