Skip to content

Add automation-friendly flags (--yes, --noconfirm)#1

Merged
snomiao merged 1 commit intomainfrom
feature/automation-flags
Feb 17, 2026
Merged

Add automation-friendly flags (--yes, --noconfirm)#1
snomiao merged 1 commit intomainfrom
feature/automation-flags

Conversation

@snomiao
Copy link
Copy Markdown
Owner

@snomiao snomiao commented Feb 17, 2026

Summary

Ported from insanum/gcalcli#861 by @Aurelian-Shuttleworth.

  • Added --yes / --noconfirm / --force / --no-prompt flags to bypass confirmation prompts
  • Added --noprompt flag for non-interactive event creation (delete, import)
  • Added docs/automation.md with usage guide

Why

  • Automation: Enables true headless/CI operation without pipeline hangs
  • Idempotency: Prevents interactive prompts blocking scripts

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings February 17, 2026 10:23
@snomiao snomiao merged commit a11d2c9 into main Feb 17, 2026
4 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds automation-friendly command-line flags to enable headless/CI operation of gcalcli, ported from a community contribution. The changes allow scripts to bypass interactive confirmation prompts when deleting events or importing calendar data.

Changes:

  • Added automation flags (--yes, --force, --no-prompt) that set a noconfirm option to skip confirmation prompts
  • Integrated automation flags with the delete and import commands
  • Modified _delete_event to check for noconfirm option in addition to existing expert flag
  • Modified ImportICS to skip prompts when noconfirm is set
  • Added event summary display before delete confirmation prompt for better UX
  • Added documentation for automation features

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 8 comments.

File Description
gcalcli/argparsers.py Added get_automation_parser() function defining three flag aliases (--yes, --force, --no-prompt) that set dest='noconfirm'; integrated automation_parser into delete and import subcommands; updated --iamaexpert help text to indicate it's a legacy alias
gcalcli/gcal.py Modified _delete_event to check self.options.get('noconfirm') alongside self.expert flag; added event summary display before confirmation prompt; modified ImportICS to skip prompts when noconfirm is set
docs/automation.md New documentation file describing automation flags and their use cases for CI/CD workflows

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

# 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.
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.

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

Suggested change

Copilot uses AI. Check for mistakes.
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.

# 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.
Comment on lines +357 to +378
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
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 +1000 to 1003
if self.expert or self.options.get('noconfirm'):
self.delete(cal_id, event_id)
self.printer.msg('Deleted!\n', 'red')
return
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.
Comment on lines +1653 to 1656
if not verbose or self.options.get('noconfirm'):
# Don't prompt, just assume user wants to import.
pass
else:
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.
Comment on lines +357 to +378
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
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants