Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/automation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Automation Guide

`gcalcli` provides features specifically designed for automation scripts and agents.

## Non-Interactive Mode support (CI/CD)

Use automation flags to prevent the tool from pausing for user input:

- `--yes`, `--force`, `--no-prompt`: Automatically answer "yes" to confirmation prompts (like delete).
- `--noprompt` (specific to `add`): Skips prompting for missing fields during event creation.
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

Incorrect documentation: The flag --noprompt mentioned here is specific to the add command and controls whether to prompt for missing event fields during creation (it sets dest='prompt' with action='store_false'). It is not related to the automation flags (--yes, --force, --no-prompt) that control confirmation prompts for delete and import operations. The --noprompt flag should not be mentioned in this automation context, or should be clarified that it only applies to the add command for a different purpose.

Suggested change
- `--noprompt` (specific to `add`): Skips prompting for missing fields during event creation.

Copilot uses AI. Check for mistakes.
33 changes: 30 additions & 3 deletions gcalcli/argparsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,30 @@ def get_search_parser():
return search_parser


def get_automation_parser():
# Flags for skipping confirmation prompts
automation_parser = argparse.ArgumentParser(add_help=False)
automation_parser.add_argument(
'--yes', '-y',
action='store_true',
dest='noconfirm',
help='Answer "yes" to all prompts (e.g. delete confirmation)'
)
automation_parser.add_argument(
'--force', '-f',
action='store_true',
dest='noconfirm',
help='Alias for --yes'
)
automation_parser.add_argument(
'--no-prompt',
action='store_true',
dest='noconfirm',
help='Alias for --yes'
)
return automation_parser
Comment on lines +357 to +378
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

Missing test coverage for the new automation parser. The codebase has established patterns for testing argument parsers in tests/test_argparsers.py (e.g., test_reminder_parser, test_output_parser, test_search_parser). A test should be added to verify that the automation parser correctly sets the 'noconfirm' destination when any of the flags (--yes, -y, --force, -f, --no-prompt) are used. This would follow the pattern of other parser tests and ensure the flags work as expected.

Copilot uses AI. Check for mistakes.
Comment on lines +357 to +378
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

The PR description claims to add a --noconfirm flag, but this flag does not exist in the implementation. The implemented flags are --yes, --force, and --no-prompt, all of which set the internal noconfirm destination. The PR description should be corrected to accurately reflect the implemented flags, or a --noconfirm flag should be added if it was intended.

Copilot uses AI. Check for mistakes.


def handle_unparsed(unparsed, namespace):
# Attempt a reparse against the program options.
# Provides some robustness for misplaced global options
Expand Down Expand Up @@ -450,6 +474,9 @@ def get_argument_parser():

# tacks on search text
search_parser = get_search_parser()

Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

Trailing whitespace at the end of this line. This should be removed to maintain code cleanliness.

Copilot uses AI. Check for mistakes.
# automation flags
automation_parser = get_automation_parser()

sub = parser.add_subparsers(
help='Invoking a subcommand with --help prints subcommand usage.',
Expand Down Expand Up @@ -496,13 +523,13 @@ def get_argument_parser():

delete = sub.add_parser(
'delete',
parents=[calendars_parser, output_parser, search_parser],
parents=[calendars_parser, output_parser, search_parser, automation_parser],
help='delete events from the calendar',
description='Case insensitive search for items to delete '
'interactively.',
)
delete.add_argument(
'--iamaexpert', action='store_true', help='Probably not'
'--iamaexpert', action='store_true', help='Legacy alias for --yes'
)

sub.add_parser(
Expand Down Expand Up @@ -656,7 +683,7 @@ def get_argument_parser():

_import = sub.add_parser(
'import',
parents=[calendar_parser, remind_parser],
parents=[calendar_parser, remind_parser, automation_parser],
help='import an ics/vcal file to a calendar',
description='Import from an ics/vcal file; a single --calendar '
'must be specified. Reads from stdin when no file argument is '
Expand Down
11 changes: 9 additions & 2 deletions gcalcli/gcal.py
Original file line number Diff line number Diff line change
Expand Up @@ -997,11 +997,18 @@ def _delete_event(self, event):
cal_id = event['gcalcli_cal']['id']
event_id = event['id']

if self.expert:
if self.expert or self.options.get('noconfirm'):
self.delete(cal_id, event_id)
self.printer.msg('Deleted!\n', 'red')
return
Comment on lines +1000 to 1003
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

Missing test coverage for the noconfirm flag behavior in delete operations. The codebase has existing tests for ImportICS in tests/test_gcalcli.py. Similar integration tests should be added to verify that when the noconfirm option is set, the _delete_event method bypasses the confirmation prompt and deletes the event directly, similar to how the expert flag currently works.

Copilot uses AI. Check for mistakes.

# Print "Safe Prompt" summary
time_str = event['s'].strftime('%Y-%m-%d %H:%M')
if is_all_day(event):
time_str = event['s'].strftime('%Y-%m-%d')
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

Inconsistent indentation: this line uses a space for indentation while the rest of the file uses 4-space indents. This should use 4 spaces to match the surrounding code.

Suggested change
time_str = event['s'].strftime('%Y-%m-%d')
time_str = event['s'].strftime('%Y-%m-%d')

Copilot uses AI. Check for mistakes.

Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

Trailing whitespace at the end of this line. This should be removed to maintain code cleanliness.

Suggested change

Copilot uses AI. Check for mistakes.
self.printer.msg(f'> Found Event: "{_valid_title(event).strip()}" ({time_str})\n', 'yellow')

self.printer.msg('Delete? [N]o [y]es [q]uit: ', 'magenta')
val = input()

Expand Down Expand Up @@ -1643,7 +1650,7 @@ def ImportICS(self, verbose=False, dump=False, reminders=None,

self._add_reminders(event.body, reminders)

if not verbose:
if not verbose or self.options.get('noconfirm'):
# Don't prompt, just assume user wants to import.
pass
else:
Comment on lines +1653 to 1656
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

Missing test coverage for the noconfirm flag behavior in import operations. The codebase has existing tests for ImportICS (test_new_import_api, test_legacy_import) in tests/test_gcalcli.py. These tests should be extended to verify that when the noconfirm option is set, the ImportICS method skips the interactive prompt and imports events automatically, similar to when verbose is False.

Copilot uses AI. Check for mistakes.
Expand Down