Browse Source

Parameter renamings, default start date to today

pull/287/head
nicfb 3 years ago
parent
commit
16cbbb6db6
2 changed files with 9 additions and 9 deletions
  1. +8
    -8
      kosmorro/__main__.py
  2. +1
    -1
      kosmorro/exceptions.py

+ 8
- 8
kosmorro/__main__.py View File

@@ -120,7 +120,7 @@ def run():
output = get_search_information( output = get_search_information(
args.search, args.search,
args.from_, args.from_,
args.to,
args.until,
timezone, timezone,
output_format, output_format,
use_colors, use_colors,
@@ -245,20 +245,20 @@ def get_information(
def get_search_information( def get_search_information(
requested_events: [EventType], requested_events: [EventType],
search_from: date, search_from: date,
search_to: date,
search_until: date,
timezone: int, timezone: int,
output_format: str, output_format: str,
colors: bool, colors: bool,
show_graph: bool, show_graph: bool,
) -> dumper.Dumper: ) -> dumper.Dumper:
try: try:
if search_from is None or search_to is None:
if search_until is None:
raise SearchDatesNotGivenError raise SearchDatesNotGivenError


event_types = [EventType[event.upper()] for event in requested_events] event_types = [EventType[event.upper()] for event in requested_events]
from_ = parse_date(search_from) 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]( return get_dumpers()[output_format](
ephemerides=[], ephemerides=[],
@@ -398,11 +398,11 @@ def get_args(output_formats: [str]):
"--from", "--from",
dest="from_", dest="from_",
type=str, 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( 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( parser.add_argument(
"--no-colors", "--no-colors",


+ 1
- 1
kosmorro/exceptions.py View File

@@ -70,7 +70,7 @@ class SearchDatesNotGivenError(RuntimeError):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.msg = _( self.msg = _(
"Both 'from' and 'to' dates are required when searching for events."
"Search end date (--until) is required when searching events.'"
) )






Loading…
Cancel
Save