Skip to content

Add JSON-first CLI companion binary and DB CRUD helpers (solverforge-calendar-cli)#1

Open
blackopsrepl wants to merge 2 commits intomainfrom
codex/add-cli-tool-for-crud-operations
Open

Add JSON-first CLI companion binary and DB CRUD helpers (solverforge-calendar-cli)#1
blackopsrepl wants to merge 2 commits intomainfrom
codex/add-cli-tool-for-crud-operations

Conversation

@blackopsrepl
Copy link
Copy Markdown
Owner

Motivation

  • Provide a pure-CLI, JSON-first companion binary for scripting and tool integration (e.g. OpenClaw) so automation can perform CRUD and Google sync operations without the TUI.
  • Expose missing database CRUD helpers and query primitives to support CLI operations against calendars, projects, events, dependencies, and sync tokens.

Description

  • Add a new binary src/bin/solverforge-calendar-cli.rs implementing a JSON-first CLI that supports calendars, projects, events, dependencies, and google sync with list|get|create|update|delete actions, flag parsing, validation, and pretty JSON output.
  • Extend src/db.rs with multiple helper functions including load_events, get_calendar, insert/update/soft_delete for calendars and projects, get_event, get_dependency, insert/update/delete for dependencies, now_timestamp, and wiring for event-range queries and single-row fetches.
  • Add CLI-side validation and utilities in the CLI binary, including datetime validation, dependency validation, parsing helpers for booleans/integers/enums, and use of a tokio runtime for Google calendar sync via google::sync::sync_calendar.
  • Update README.md to document the new CLI usage, examples and supported CRUD groups, and add a short note about the JSON-first semantics for automation.

Testing

  • Ran a local release build of both binaries with cargo build --bins which completed successfully.
  • Ran the test suite with cargo test which completed successfully (no failing tests reported).
  • Performed a local smoke run of the CLI help path (solverforge-calendar-cli help) to verify usage output and JSON formatting logic was reachable.

Codex Task

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c6daa00b07

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +573 to +576
require_resource(db::get_event(conn, from_event_id)?, "event", from_event_id)
.context("from-event-id must reference an existing non-deleted event")?;
require_resource(db::get_event(conn, to_event_id)?, "event", to_event_id)
.context("to-event-id must reference an existing non-deleted event")?;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Reject cycle-forming dependency edges

validate_dependency only verifies that both event IDs exist and are distinct, so dependencies create/update can persist cycles (for example, creating A -> B and then B -> A). The scheduler DAG builder explicitly skips cycle-forming edges, so persisted dependencies can diverge from runtime dependency behavior and produce inconsistent results for users and automation. Add cycle detection against existing blocks edges before insert/update.

Useful? React with 👍 / 👎.

Some(next) if !next.starts_with("--") => iter.next(),
_ => None,
};
flags.insert(key, value);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject unknown flags instead of silently accepting them

The parser accepts any --<key> and stores it, but resource handlers only read known keys and never fail on extras. That means typoed optional flags (for example --reminder-minute instead of --reminder-minutes) are silently ignored while the command still returns success JSON, which can corrupt automation workflows by hiding failed intent. Unknown flags should be validated per action and surfaced as errors.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant