Skip to content

Commit

Permalink
Rename 'from' to 'until'
Browse files Browse the repository at this point in the history
Make today default search start date
  • Loading branch information
nicfb committed Nov 4, 2022
1 parent dc587f3 commit 16a9b29
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions kosmorro/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def run():
output = get_search_information(
args.search,
args.from_,
args.to,
args.until,
timezone,
output_format,
use_colors,
Expand Down Expand Up @@ -245,20 +245,20 @@ def get_information(
def get_search_information(
requested_events: [EventType],
search_from: date,
search_to: date,
search_until: date,
timezone: int,
output_format: str,
colors: bool,
show_graph: bool,
) -> dumper.Dumper:
try:
if search_from is None or search_to is None:
if search_until is None:
raise SearchDatesNotGivenError

event_types = [EventType[event.upper()] for event in requested_events]
from_ = parse_date(search_from)
to = parse_date(search_to)
events_list = search_events(event_types, to, from_, timezone)
until = parse_date(search_until)
events_list = search_events(event_types, until, from_, timezone)

return get_dumpers()[output_format](
ephemerides=[],
Expand Down Expand Up @@ -398,11 +398,11 @@ def get_args(output_formats: [str]):
"--from",
dest="from_",
type=str,
default=None,
help=_("The date to begin searching for events."),
default=today.strftime("%Y-%m-%d"),
help=_("The date to begin searching for events. Default is today."),
)
parser.add_argument(
"--to", type=str, default=None, help=_("The date to end searching for events.")
"--until", type=str, default=None, help=_("The date to end searching for events.")
)
parser.add_argument(
"--no-colors",
Expand Down
2 changes: 1 addition & 1 deletion kosmorro/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class SearchDatesNotGivenError(RuntimeError):
def __init__(self):
super().__init__()
self.msg = _(
"Both 'from' and 'to' dates are required when searching for events."
"Search end date (--until) is required when searching events.'"
)


Expand Down

0 comments on commit 16a9b29

Please sign in to comment.