feat: add --availability flag for event transparency#868
feat: add --availability flag for event transparency#868Aurelian-Shuttleworth wants to merge 2 commits intoinsanum:mainfrom
Conversation
- Add Transparency handler to details.py - Add --transparency flag to argparsers.py - Update CLI wiring to pass transparency arg - Add regression test
- Rename CLI flag to --availability - Update choices to free/busy - Map free->transparent and busy->opaque in gcal.py - Rename Transparency handler to Availability and update display logic - Update tests
Code Review Completed! 🔥The code review was successfully completed based on your current configurations. Automatic Review: Kody reviews this PR automatically on every push. Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
| add.add_argument( | ||
| '--availability', | ||
| default='busy', | ||
| choices=['free', 'busy'], | ||
| help='Event availability (free/busy status). Default is busy.', | ||
| ) |
There was a problem hiding this comment.
The code uses user-friendly values ('free', 'busy') instead of the Google Calendar API's required values ('transparent', 'opaque') for the event availability/transparency field. This mismatch causes API errors and prevents the feature from working correctly.
This issue appears in multiple locations:
- gcalcli/argparsers.py: Lines 612-617
- gcalcli/details.py: Lines 359-367
Please ensure all code handling event availability translates between user-facing terms ('free'/'busy') and API-required values ('transparent'/'opaque') consistently across the codebase.
add.add_argument(
'--availability',
dest='transparency',
default='opaque',
choices=['transparent', 'opaque'],
help='Event availability. Use "transparent" for free, "opaque" for busy. Default is opaque.',
)Prompt for LLM
File gcalcli/argparsers.py:
Line 612 to 617:
The provided Python code adds a new command-line argument `--availability` to a tool that interacts with the Google Calendar API. The argument is intended to control the event's 'transparency' property, which makes an event appear as 'Free' or 'Busy' on the calendar.
The current implementation defines the choices for this argument as 'free' and 'busy'. However, the Google Calendar API's `transparency` field requires the literal string values 'transparent' or 'opaque'.
The code is missing a step to translate the user-friendly values ('free', 'busy') into the API-required values ('transparent', 'opaque'). This will cause API errors when the feature is used.
Please refactor the `add_argument` call to fix this issue. The most direct solution is to use the API-compliant values directly. You should also update the `dest` parameter to 'transparency' to match the API field name, change the `default` value to its API equivalent, and update the `help` text to guide the user correctly.
Suggested Code:
add.add_argument(
'--availability',
dest='transparency',
default='opaque',
choices=['transparent', 'opaque'],
help='Event availability. Use "transparent" for free, "opaque" for busy. Default is opaque.',
)
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.
| gcal = PatchedGCalI( | ||
| cal_names=cal_names, allday=False, default_reminders=True) | ||
| assert gcal.AddEvent(title='transparent event', | ||
| where='anywhere', | ||
| start='now', | ||
| end='tomorrow', | ||
| descr='testing', | ||
| who='anyone', | ||
| reminders=None, | ||
| color='banana', | ||
| availability='free') |
There was a problem hiding this comment.
The test passes the availability option as a keyword argument to the AddEvent method. However, command-line options are typically used to initialize the GCalI object's state via its constructor. The AddEvent method would then read this state from self.options.availability rather than accepting it as a direct parameter.
This approach tests a method signature that likely differs from the production code, which will cause the test to fail with a TypeError: AddEvent() got an unexpected keyword argument 'availability' before the actual logic can be verified. The availability option should be passed to the PatchedGCalI constructor to correctly simulate the application's behavior.
gcal = PatchedGCalI(
cal_names=cal_names, allday=False, default_reminders=True,
availability='free')
assert gcal.AddEvent(title='transparent event',
where='anywhere',
start='now',
end='tomorrow',
descr='testing',
who='anyone',
reminders=None,
color='banana')Prompt for LLM
File tests/test_gcalcli.py:
Line 399 to 409:
The provided Python test case is flawed. It attempts to test a new 'availability' feature by passing `availability='free'` as a keyword argument directly to the `AddEvent` method. However, in this command-line application, options like this are typically passed to the main class's constructor to set its internal state (e.g., `self.options`). The `AddEvent` method would then read the availability from this internal state, not from a direct method argument. Because the test calls the method with an unexpected keyword argument, it will raise a `TypeError` and crash before it can verify the feature's logic. Please refactor the test to pass the `availability` option to the `PatchedGCalI` constructor instead of the `AddEvent` method call, which will correctly simulate the application's behavior and allow the test to validate the implementation.
Suggested Code:
gcal = PatchedGCalI(
cal_names=cal_names, allday=False, default_reminders=True,
availability='free')
assert gcal.AddEvent(title='transparent event',
where='anywhere',
start='now',
end='tomorrow',
descr='testing',
who='anyone',
reminders=None,
color='banana')
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.
Summary
Added a new
--availabilityflag to theaddcommand, allowing users to explicitly set an event as "Free" or "Busy".Why
Resolves #867.
Currently,
gcalclidefaults all new events to "Busy" (Opaque). Users need the ability to create "Ghost Blocks" — events that are visible for planning but do not block scheduling availability.This PR exposes the Google Calendar API
transparencyfield via a user-friendly--availabilityflag.Verification
test_add_event_availabilitytotests/test_gcalcli.py. Verified withpytest.gcalcli add ... --availability free-> Event created as "Free".gcalcli add ... --availability busy-> Event created as "Busy".Checklist
README.md)This pull request introduces a new
--availabilityflag to theaddcommand, allowing users to specify their free/busy status for new events.Key changes include:
--availabilityflag: Users can now set an event's availability tofreeorbusy(defaulting tobusy) when creating it.transparencyfield (transparentforfree,opaqueforbusy) when an event is added.--availability freecorrectly set thetransparencyfield totransparent.