-
Notifications
You must be signed in to change notification settings - Fork 0
feat: support [default] section in config.toml for global flag defaults #7
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,48 @@ | ||
| # Configuration | ||
|
|
||
| `gcalcli` supports configuration via a `config.toml` file, typically located at `~/.config/gcalcli/config.toml` (or `$XDG_CONFIG_HOME/gcalcli/config.toml`). | ||
|
|
||
| ## Structure | ||
|
|
||
| The configuration is divided into sections: | ||
|
|
||
| ### `[auth]` | ||
|
|
||
| Settings for authentication (Client ID). | ||
|
|
||
| ### `[calendars]` | ||
|
|
||
| Settings for default and ignored calendars. | ||
|
|
||
| ### `[output]` | ||
|
|
||
| Settings for output formatting (week start). | ||
|
|
||
| ### `[default]` (New) | ||
|
|
||
| Set default values for global command-line flags. | ||
|
|
||
| ```toml | ||
| [default] | ||
| interactive = false # Disable interactive prompts (simulates --yes) | ||
| color = true # Enable/Disable color | ||
| conky = false # Conky compatible output | ||
| ``` | ||
|
|
||
| ## Example `config.toml` | ||
|
|
||
| ```toml | ||
| [auth] | ||
| client-id = "your-client-id.apps.googleusercontent.com" | ||
|
|
||
| [calendars] | ||
| default-calendars = ["Work", "Personal"] | ||
| ignore-calendars = ["Holidays"] | ||
|
|
||
| [output] | ||
| week-start = "monday" | ||
|
|
||
| [default] | ||
| interactive = true | ||
| color = true | ||
| ``` | ||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -502,7 +502,7 @@ def get_argument_parser(): | |||||||||
| 'interactively.', | ||||||||||
| ) | ||||||||||
| delete.add_argument( | ||||||||||
| '--iamaexpert', action='store_true', help='Probably not' | ||||||||||
| '--iamaexpert', action='store_true', help='Legacy alias for --yes' | ||||||||||
|
||||||||||
| '--iamaexpert', action='store_true', help='Legacy alias for --yes' | |
| '--iamaexpert', | |
| action='store_true', | |
| help='Skip delete confirmation prompt (legacy expert flag)', |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -193,17 +193,16 @@ def main(): | |
| opts_from_config = config.Config() | ||
|
|
||
| namespace_from_config = opts_from_config.to_argparse_namespace() | ||
| # Pull week_start aside and set it manually after parse_known_args. | ||
| # TODO: Figure out why week_start from opts_from_config getting through. | ||
| week_start = namespace_from_config.week_start | ||
| namespace_from_config.week_start = None | ||
|
|
||
| # Apply config values as defaults for the parser. | ||
| # This allows config to override program defaults, while still letting | ||
| # explicit CLI arguments override config. | ||
| parser.set_defaults(**vars(namespace_from_config)) | ||
|
|
||
| if parsed_args.includeRc: | ||
| argv = fromfile_args + argv | ||
| (parsed_args, unparsed) = parser.parse_known_args( | ||
| argv, namespace=namespace_from_config | ||
| ) | ||
| if parsed_args.week_start is None: | ||
| parsed_args.week_start = week_start | ||
| (parsed_args, unparsed) = parser.parse_known_args(argv) | ||
|
|
||
|
Comment on lines
+197
to
+205
|
||
| if parsed_args.config_folder: | ||
| parsed_args.config_folder = parsed_args.config_folder.expanduser() | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -70,6 +70,30 @@ class OutputSection(BaseModel): | |||||||||||||
| ) | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
| class DefaultSection(BaseModel): | ||||||||||||||
| model_config = ConfigDict( | ||||||||||||||
| title='Default Global Options' | ||||||||||||||
| ) | ||||||||||||||
|
|
||||||||||||||
| interactive: bool = Field( | ||||||||||||||
| alias='interactive', | ||||||||||||||
| title='Enable interactive mode (default: true)', | ||||||||||||||
| default=True | ||||||||||||||
| ) | ||||||||||||||
|
Comment on lines
+77
to
+82
|
||||||||||||||
| interactive: bool = Field( | |
| alias='interactive', | |
| title='Enable interactive mode (default: true)', | |
| default=True | |
| ) |
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.
Config now supports a [default] section and merges it into the argparse namespace. There are currently no unit tests covering TOML parsing for this new section (or verifying that its values appear in to_argparse_namespace()), despite the repository having a tests/ suite. Please add a test that loads a minimal TOML with [default] and asserts the resulting namespace contains the expected values.
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.
This section documents
interactive = falseas “simulates --yes”, but there is no--yesflag in the current CLI (onlydelete --iamaexpertexists) and the newly-addedinteractiveconfig key is not used by the application. Update the documentation to describe the actual supported flags/behavior, or implement the promised--yes/non-interactive behavior.