-
Notifications
You must be signed in to change notification settings - Fork 0
Add automation-friendly flags (--yes, --noconfirm) #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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
|
||
|
|
||
|
|
||
| def handle_unparsed(unparsed, namespace): | ||
| # Attempt a reparse against the program options. | ||
| # Provides some robustness for misplaced global options | ||
|
|
@@ -450,6 +474,9 @@ def get_argument_parser(): | |
|
|
||
| # tacks on search text | ||
| search_parser = get_search_parser() | ||
|
|
||
|
||
| # automation flags | ||
| automation_parser = get_automation_parser() | ||
|
|
||
| sub = parser.add_subparsers( | ||
| help='Invoking a subcommand with --help prints subcommand usage.', | ||
|
|
@@ -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( | ||
|
|
@@ -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 ' | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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
|
||||||
|
|
||||||
| # 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') | ||||||
|
||||||
| time_str = event['s'].strftime('%Y-%m-%d') | |
| time_str = event['s'].strftime('%Y-%m-%d') |
Copilot
AI
Feb 17, 2026
There was a problem hiding this comment.
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
AI
Feb 17, 2026
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incorrect documentation: The flag
--nopromptmentioned here is specific to theaddcommand and controls whether to prompt for missing event fields during creation (it setsdest='prompt'withaction='store_false'). It is not related to the automation flags (--yes,--force,--no-prompt) that control confirmation prompts for delete and import operations. The--nopromptflag should not be mentioned in this automation context, or should be clarified that it only applies to theaddcommand for a different purpose.