Skip to content

Commit 9cf9593

Browse files
committed
feat: Add generate command to CLI
Added a new `generate` command to the CLI that allows for the generation of HTML and ICS files from existing event data without performing a new collection. This command takes an optional output file path and configuration file path. The Makefile was also updated to include a target for generating HTML. Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com>
1 parent a34a780 commit 9cf9593

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1-
gen:
1+
all:
22
@uv run cfp-radar collect
3+
4+
html:
5+
@uv run cfp-radar generate

src/cli.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,21 @@ def main() -> None:
3838
help="Path to config YAML file (default: config.yaml)",
3939
)
4040

41+
# Generate HTML command (no collection)
42+
generate_parser = subparsers.add_parser(
43+
"generate", help="Generate HTML from existing event data (no collection)"
44+
)
45+
generate_parser.add_argument(
46+
"output_file",
47+
nargs="?",
48+
default="data/index.html",
49+
help="HTML output file (default: data/index.html)",
50+
)
51+
generate_parser.add_argument(
52+
"--config",
53+
help="Path to config YAML file (default: config.yaml)",
54+
)
55+
4156
# Notify command
4257
notify_parser = subparsers.add_parser(
4358
"notify", help="Send Slack notifications for upcoming CFPs"
@@ -63,6 +78,8 @@ def main() -> None:
6378

6479
if args.command == "collect":
6580
asyncio.run(cmd_collect(args))
81+
elif args.command == "generate":
82+
cmd_generate(args)
6683
elif args.command == "notify":
6784
asyncio.run(cmd_notify(args))
6885
elif args.command == "list":
@@ -117,6 +134,31 @@ async def cmd_collect(args: argparse.Namespace) -> None:
117134
logger.info("ICS calendar written to: %s", ics_output)
118135

119136

137+
def cmd_generate(args: argparse.Namespace) -> None:
138+
"""Generate HTML and ICS from existing event data without collecting."""
139+
from datetime import date
140+
141+
from .collector.models import EventStore
142+
from .config import EVENTS_FILE, set_config_file
143+
from .generator import generate_html
144+
145+
if args.config:
146+
set_config_file(args.config)
147+
148+
store = EventStore(EVENTS_FILE)
149+
events = store.filter(start_after=date.today())
150+
logger.info("Total events: %d", len(events))
151+
152+
generate_html(events, args.output_file)
153+
logger.info("HTML output written to: %s", args.output_file)
154+
155+
from .calendar_feed import generate_ics
156+
157+
ics_output = os.path.join(os.path.dirname(args.output_file) or ".", "events.ics")
158+
generate_ics(events, ics_output)
159+
logger.info("ICS calendar written to: %s", ics_output)
160+
161+
120162
async def cmd_notify(args: argparse.Namespace) -> None:
121163
"""Send Slack notifications."""
122164
from .notifier import check_upcoming_cfps

0 commit comments

Comments
 (0)