config-cli-gui 0.2.10__tar.gz → 0.3.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/HISTORY.md +28 -0
  2. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/PKG-INFO +23 -1
  3. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/README.md +64 -38
  4. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/config.yaml +36 -39
  5. config_cli_gui-0.3.1/docs/_static/img/settings_dlg.png +0 -0
  6. config_cli_gui-0.3.1/docs/_static/img/settings_doc.png +0 -0
  7. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/docs/index.md +22 -0
  8. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/src/config_cli_gui/_version.py +3 -3
  9. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/src/config_cli_gui/cli.py +15 -10
  10. config_cli_gui-0.3.1/src/config_cli_gui/config.py +256 -0
  11. config_cli_gui-0.3.1/src/config_cli_gui/configtypes/font.py +133 -0
  12. config_cli_gui-0.3.1/src/config_cli_gui/logging.py +216 -0
  13. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/src/config_cli_gui.egg-info/PKG-INFO +23 -1
  14. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/src/config_cli_gui.egg-info/SOURCES.txt +3 -1
  15. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/tests/example_project/cli/cli_example.py +29 -8
  16. config_cli_gui-0.3.1/tests/example_project/core/base.py +116 -0
  17. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/tests/example_project/gui/gui_example.py +4 -4
  18. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/tests/test_cli.py +19 -1
  19. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/tests/test_config_manager.py +6 -1
  20. config_cli_gui-0.2.10/src/config_cli_gui/config.py +0 -223
  21. config_cli_gui-0.2.10/src/config_cli_gui/configtypes/font.py +0 -80
  22. config_cli_gui-0.2.10/tests/example_project/core/base.py +0 -55
  23. config_cli_gui-0.2.10/tests/example_project/core/logging.py +0 -219
  24. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/.github/FUNDING.yml +0 -0
  25. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  26. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
  27. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
  28. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/.github/actions/setup-environment/action.yml +0 -0
  29. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/.github/dependabot.yml +0 -0
  30. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/.github/init.sh +0 -0
  31. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/.github/release_message.sh +0 -0
  32. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/.github/update_funding.py +0 -0
  33. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/.github/workflows/main.yml +0 -0
  34. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/.github/workflows/release.yml +0 -0
  35. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/.github/workflows/update_readme.yml +0 -0
  36. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/.gitignore +0 -0
  37. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/.idea/runConfigurations/config_generate.xml +0 -0
  38. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/.idea/runConfigurations/example_project_cli.xml +0 -0
  39. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/.idea/runConfigurations/example_project_gui.xml +0 -0
  40. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/.pre-commit-config.yaml +0 -0
  41. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/.readthedocs.yaml +0 -0
  42. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/LICENSE +0 -0
  43. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/Makefile +0 -0
  44. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/docs/.nav.yml +0 -0
  45. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/docs/_static/img/favicon.png +0 -0
  46. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/docs/_static/img/logo.png +0 -0
  47. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/docs/css/custom.css +0 -0
  48. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/docs/develop/contributing.md +0 -0
  49. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/docs/develop/make_windows.md +0 -0
  50. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/docs/develop/naming_convention.md +0 -0
  51. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/docs/funding/funding.md +0 -0
  52. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/docs/getting-started/install.md +0 -0
  53. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/docs/getting-started/virtual-environment.md +0 -0
  54. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/docs/usage/cli.md +0 -0
  55. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/docs/usage/config.md +0 -0
  56. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/mkdocs.yml +0 -0
  57. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/pyproject.toml +0 -0
  58. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/scripts/show_filelist.ps1 +0 -0
  59. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/scripts/show_tree.ps1 +0 -0
  60. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/scripts/show_tree.py +0 -0
  61. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/scripts/update_readme.py +0 -0
  62. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/setup.cfg +0 -0
  63. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/src/__init__.py +0 -0
  64. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/src/config_cli_gui/__init__.py +0 -0
  65. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/src/config_cli_gui/configtypes/__init__.py +0 -0
  66. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/src/config_cli_gui/configtypes/color.py +0 -0
  67. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/src/config_cli_gui/configtypes/vector.py +0 -0
  68. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/src/config_cli_gui/docs.py +0 -0
  69. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/src/config_cli_gui/gui.py +0 -0
  70. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/src/config_cli_gui.egg-info/dependency_links.txt +0 -0
  71. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/src/config_cli_gui.egg-info/entry_points.txt +0 -0
  72. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/src/config_cli_gui.egg-info/requires.txt +0 -0
  73. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/src/config_cli_gui.egg-info/top_level.txt +0 -0
  74. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/template.yml.url +0 -0
  75. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/tests/__init__.py +0 -0
  76. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/tests/example_project/__init__.py +0 -0
  77. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/tests/example_project/__main__.py +0 -0
  78. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/tests/example_project/cli/__init__.py +0 -0
  79. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/tests/example_project/cli/__main__.py +0 -0
  80. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/tests/example_project/config/__init__.py +0 -0
  81. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/tests/example_project/config/config_example.py +0 -0
  82. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/tests/example_project/core/__init__.py +0 -0
  83. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/tests/example_project/example.gpx +0 -0
  84. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/tests/example_project/gui/__init__.py +0 -0
  85. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/tests/example_project/gui/__main__.py +0 -0
  86. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/tests/example_project/gui/config.yaml +0 -0
  87. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/tests/test_docs.py +0 -0
  88. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/tests/test_generic_cli.py +0 -0
  89. {config_cli_gui-0.2.10 → config_cli_gui-0.3.1}/uv.lock +0 -0
@@ -2,6 +2,34 @@ Changelog
2
2
  =========
3
3
 
4
4
 
5
+ (unreleased)
6
+ ------------
7
+ - Fix typings, improve cli test. [Paul Magister]
8
+ - Update README.md from docs/index.md. [github-actions]
9
+ - Improve doc. [Paul Magister]
10
+ - Search for some more paths in windows. [Paul Magister]
11
+
12
+
13
+ 0.3.0 (2025-12-03)
14
+ ------------------
15
+ - Docs: Update HISTORY.md for release 0.3.0. [Paul Magister]
16
+ - Docs: Update HISTORY.md for release 0.2.9. [Paul Magister]
17
+ - Refactoring: config parameters will stay ordered like in the config.
18
+ [Paul Magister]
19
+ - Refactoring: config parameters will stay ordered like in the config.
20
+ [Paul Magister]
21
+ - Refactor cli.py, move logging into this project. [Paul Magister]
22
+ - Docs: Update HISTORY.md for release 0.2.9. [Paul Magister]
23
+ - Docs: Update HISTORY.md for release 0.2.10. [Paul Magister]
24
+ - Docs: Update HISTORY.md for release 0.2.9. [Paul Magister]
25
+ - Update README.md from docs/index.md. [github-actions]
26
+
27
+
28
+ 0.2.10 (2025-12-03)
29
+ -------------------
30
+ - Docs: Update HISTORY.md for release 0.2.10. [Paul Magister]
31
+
32
+
5
33
  0.2.9 (2025-12-03)
6
34
  ------------------
7
35
  - Docs: Update HISTORY.md for release 0.2.9. [Paul Magister]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: config-cli-gui
3
- Version: 0.2.10
3
+ Version: 0.3.1
4
4
  Summary: Feature-rich Python project template for config-cli-gui.
5
5
  Author: pamagister
6
6
  Requires-Python: <3.12,>=3.10
@@ -63,11 +63,33 @@ pip install config-cli-gui
63
63
  ## ✨ Features
64
64
 
65
65
  * **Single Source of Truth**: Define all your application parameters in one place using simple, dataclass-like structures based on Pydantic's `BaseModel`. This ensures consistency and reduces errors across your application.
66
+
67
+ ```yaml
68
+ gui:
69
+ # GUI theme setting | type=str | choices=['light', 'dark', 'auto']
70
+ theme: light
71
+ misc:
72
+ # Example integer | type=int
73
+ some_numeric: 42
74
+ # Path to the file to use | type=PosixPath
75
+ some_file: some_file.txt
76
+ # Color setting for the application | type=Color
77
+ some_color: '#ff0000'
78
+ # Font setting for the application | type=Font
79
+ some_font: 'DejaVuSans.ttf, 12, #0000ff'
80
+ ```
81
+
66
82
  * **Categorized Configuration**: Organize your parameters into logical categories (e.g., `cli`, `app`, `gui`) for better structure and maintainability.
67
83
  * **Dynamic CLI Generation**: Automatically generate `argparse`-compatible command-line arguments directly from your defined configuration parameters, including help texts, types, and choices.
68
84
  * **Config File Management**: Easily load and save configurations from/to YAML or JSON files, allowing users to customize default settings.
69
85
  * **GUI Settings Dialogs**: Dynamically create Tkinter-based settings dialogs for your application, allowing users to intuitively modify configuration parameters via a graphical interface.
86
+
87
+ ![settings_dlg.png](_static/img/settings_dlg.png)
88
+
70
89
  * **Documentation Generation**: Generate detailed Markdown documentation for both your CLI options and all configuration parameters, keeping your user guides always up-to-date with your codebase.
90
+
91
+ ![settings_doc.png](_static/img/settings_doc.png)
92
+
71
93
  * **Override System**: Supports robust overriding of configuration values via configuration files and command-line arguments, with clear precedence.
72
94
 
73
95
  ---
@@ -30,21 +30,38 @@ You can install `config-cli-gui` using pip:
30
30
  pip install config-cli-gui
31
31
  ```
32
32
 
33
- ## Contribution
34
-
35
- Refer to this how-to in the referenced project for getting started to install and develop on this project:
36
- https://github.com/pamagister/python-template-project
37
-
38
33
  ---
39
34
 
40
35
  ## ✨ Features
41
36
 
42
37
  * **Single Source of Truth**: Define all your application parameters in one place using simple, dataclass-like structures based on Pydantic's `BaseModel`. This ensures consistency and reduces errors across your application.
38
+
39
+ ```yaml
40
+ gui:
41
+ # GUI theme setting | type=str | choices=['light', 'dark', 'auto']
42
+ theme: light
43
+ misc:
44
+ # Example integer | type=int
45
+ some_numeric: 42
46
+ # Path to the file to use | type=PosixPath
47
+ some_file: some_file.txt
48
+ # Color setting for the application | type=Color
49
+ some_color: '#ff0000'
50
+ # Font setting for the application | type=Font
51
+ some_font: 'DejaVuSans.ttf, 12, #0000ff'
52
+ ```
53
+
43
54
  * **Categorized Configuration**: Organize your parameters into logical categories (e.g., `cli`, `app`, `gui`) for better structure and maintainability.
44
55
  * **Dynamic CLI Generation**: Automatically generate `argparse`-compatible command-line arguments directly from your defined configuration parameters, including help texts, types, and choices.
45
56
  * **Config File Management**: Easily load and save configurations from/to YAML or JSON files, allowing users to customize default settings.
46
57
  * **GUI Settings Dialogs**: Dynamically create Tkinter-based settings dialogs for your application, allowing users to intuitively modify configuration parameters via a graphical interface.
58
+
59
+ ![settings_dlg.png](_static/img/settings_dlg.png)
60
+
47
61
  * **Documentation Generation**: Generate detailed Markdown documentation for both your CLI options and all configuration parameters, keeping your user guides always up-to-date with your codebase.
62
+
63
+ ![settings_doc.png](_static/img/settings_doc.png)
64
+
48
65
  * **Override System**: Supports robust overriding of configuration values via configuration files and command-line arguments, with clear precedence.
49
66
 
50
67
  ---
@@ -67,44 +84,27 @@ from config_cli_gui.config import (
67
84
  ConfigParameter,
68
85
  )
69
86
  from config_cli_gui.configtypes.color import Color
70
- from config_cli_gui.docs import DocumentationGenerator
87
+ from config_cli_gui.configtypes.font import Font
88
+ from config_cli_gui.configtypes.vector import Vector
71
89
 
72
90
 
73
- class CliConfig(ConfigCategory):
74
- """CLI-specific configuration parameters."""
75
-
91
+ class MiscConfig(ConfigCategory):
76
92
  def get_category_name(self) -> str:
77
- return "cli"
78
-
79
- # Positional argument
80
- input: ConfigParameter = ConfigParameter(
81
- name="input",
82
- value="",
83
- help="Path to input (file or folder)",
84
- required=True,
85
- is_cli=True,
86
- )
93
+ return "misc"
87
94
 
88
- # Optional CLI arguments
89
- output: ConfigParameter = ConfigParameter(
90
- name="output",
91
- value="",
92
- help="Path to output destination",
95
+ some_numeric: ConfigParameter = ConfigParameter(
96
+ name="some_numeric",
97
+ value=int(42),
98
+ help="Example integer",
93
99
  is_cli=True,
94
100
  )
95
101
 
96
- min_dist: ConfigParameter = ConfigParameter(
97
- name="min_dist",
98
- value=20,
99
- help="Maximum distance between two waypoints",
100
- is_cli=True,
102
+ some_vector: ConfigParameter = ConfigParameter(
103
+ name="some_vector",
104
+ value=Vector(1, 2, 3),
105
+ help="Example vector",
101
106
  )
102
107
 
103
-
104
- class MiscConfig(ConfigCategory):
105
- def get_category_name(self) -> str:
106
- return "misc"
107
-
108
108
  some_file: ConfigParameter = ConfigParameter(
109
109
  name="some_file",
110
110
  value=Path("some_file.txt"),
@@ -119,20 +119,46 @@ class MiscConfig(ConfigCategory):
119
119
 
120
120
  some_date: ConfigParameter = ConfigParameter(
121
121
  name="some_date",
122
- value=datetime.now(),
122
+ value=datetime.fromisoformat("2025-12-31 10:30:45"),
123
123
  help="Date setting for the application",
124
124
  )
125
125
 
126
+ some_font: ConfigParameter = ConfigParameter(
127
+ name="some_font",
128
+ value=Font("DejaVuSans.ttf", size=12, color=Color(0, 0, 255)),
129
+ help="Font setting for the application",
130
+ )
131
+
132
+
133
+ class AppConfig(ConfigCategory):
134
+ """Application-specific configuration parameters."""
135
+
136
+ def get_category_name(self) -> str:
137
+ return "app"
138
+
139
+ log_level: ConfigParameter = ConfigParameter(
140
+ name="log_level",
141
+ value="INFO",
142
+ choices=["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"],
143
+ help="Logging level for the application",
144
+ )
145
+
146
+ log_file_max_size: ConfigParameter = ConfigParameter(
147
+ name="log_file_max_size",
148
+ value=10,
149
+ help="Maximum log file size in MB before rotation",
150
+ )
151
+
126
152
 
127
153
  class ProjectConfigManager(ConfigManager): # Inherit from ConfigManager
128
154
  """Main configuration manager that handles all parameter categories."""
129
155
 
130
- cli: CliConfig
156
+ app: AppConfig
131
157
  misc: MiscConfig
132
-
158
+
133
159
  def __init__(self, config_file: str | None = None, **kwargs):
134
160
  """Initialize the configuration manager with all parameter categories."""
135
- categories = (CliConfig(), MiscConfig())
161
+ categories = (MiscConfig(), AppConfig())
136
162
  super().__init__(categories, config_file, **kwargs)
137
163
 
138
164
 
@@ -1,63 +1,60 @@
1
+ cli:
2
+ # Path to input (file or folder) | type=str | [CLI]
3
+ input: ''
4
+ # Path to output destination | type=str | [CLI]
5
+ output: ''
6
+ # Maximum distance between two waypoints | type=int | [CLI]
7
+ min_dist: 20
8
+ # Extract starting points of each track as waypoint | type=bool | [CLI] | choices=[True, False]
9
+ extract_waypoints: true
10
+ # Include elevation data in waypoints | type=bool | [CLI] | choices=[True, False]
11
+ elevation: false
1
12
  app:
2
13
  # Date format to use | type=str
3
14
  date_format: '%Y-%m-%d'
4
- # Enable logging to console | type=bool | choices=[True, False]
5
- enable_console_logging: true
6
- # Enable logging to file | type=bool | choices=[True, False]
7
- enable_file_logging: true
8
- # Number of backup log files to keep | type=int
9
- log_backup_count: 5
15
+ # Logging level for the application | type=str | choices=['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL']
16
+ log_level: INFO
10
17
  # Maximum log file size in MB before rotation | type=int
11
18
  log_file_max_size: 10
19
+ # Number of backup log files to keep | type=int
20
+ log_backup_count: 5
12
21
  # Log message format style | type=str | choices=['simple', 'detailed', 'json']
13
22
  log_format: detailed
14
- # Logging level for the application | type=str | choices=['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL']
15
- log_level: INFO
16
23
  # Maximum number of worker threads | type=int
17
24
  max_workers: 4
18
- cli:
19
- # Include elevation data in waypoints | type=bool [CLI] | choices=[True, False]
20
- elevation: false
21
- # Extract starting points of each track as waypoint | type=bool [CLI] | choices=[True, False]
22
- extract_waypoints: true
23
- # Path to input (file or folder) | type=str [CLI]
24
- input: ''
25
- # Maximum distance between two waypoints | type=int [CLI]
26
- min_dist: 20
27
- # Path to output destination | type=str [CLI]
28
- output: ''
25
+ # Enable logging to file | type=bool | choices=[True, False]
26
+ enable_file_logging: true
27
+ # Enable logging to console | type=bool | choices=[True, False]
28
+ enable_console_logging: true
29
29
  gui:
30
- # Automatically scroll to the newest log entries | type=bool | choices=[True, False]
31
- auto_scroll_log: true
30
+ # GUI theme setting | type=str | choices=['light', 'dark', 'auto']
31
+ theme: light
32
+ # Default window width | type=int
33
+ window_width: 800
34
+ # Default window height | type=int
35
+ window_height: 600
32
36
  # Height of the log window in pixels | type=int
33
37
  log_window_height: 200
38
+ # Automatically scroll to the newest log entries | type=bool | choices=[True, False]
39
+ auto_scroll_log: true
34
40
  # Maximum number of log lines to keep in GUI | type=int
35
41
  max_log_lines: 1000
36
42
  # Point in 2D space | type=Vector
37
43
  point2D: (7, 11)
38
44
  # Point in 3D space | type=Vector
39
45
  point3D: (1.2, 3.4, 5.6)
40
- # GUI theme setting | type=str | choices=['light', 'dark', 'auto']
41
- theme: light
42
- # Default window height | type=int
43
- window_height: 600
44
- # Default window width | type=int
45
- window_width: 800
46
46
  misc:
47
- # Color setting for the application | type=Color
48
- some_color: '#ff0000'
49
- # Date setting for the application | type=datetime
50
- some_date: '2025-12-31T10:30:45'
51
- # Path to the file to use | type=PosixPath
52
- some_file: some_file.txt
53
- # Font setting for the application | type=Font
54
- some_font:
55
- - DejaVuSans.ttf
56
- - 12
57
- - '#0000ff'
58
47
  # Example integer | type=int
59
48
  some_numeric: 42
60
49
  # Example vector 2D | type=Vector
61
50
  some_vector2d: (1, 2)
62
51
  # Example vector 3D | type=Vector
63
- some_vector3d: (1.1, 2.2, 3.3)
52
+ some_vector3d: (1.1, 2.2, 3.3)
53
+ # Path to the file to use | type=PosixPath
54
+ some_file: some_file.txt
55
+ # Color setting for the application | type=Color
56
+ some_color: '#ff0000'
57
+ # Date setting for the application | type=datetime
58
+ some_date: '2025-12-31T10:30:45'
59
+ # Font setting for the application | type=Font
60
+ some_font: 'DejaVuSans.ttf, 12, #0000ff'
@@ -33,11 +33,33 @@ pip install config-cli-gui
33
33
  ## ✨ Features
34
34
 
35
35
  * **Single Source of Truth**: Define all your application parameters in one place using simple, dataclass-like structures based on Pydantic's `BaseModel`. This ensures consistency and reduces errors across your application.
36
+
37
+ ```yaml
38
+ gui:
39
+ # GUI theme setting | type=str | choices=['light', 'dark', 'auto']
40
+ theme: light
41
+ misc:
42
+ # Example integer | type=int
43
+ some_numeric: 42
44
+ # Path to the file to use | type=PosixPath
45
+ some_file: some_file.txt
46
+ # Color setting for the application | type=Color
47
+ some_color: '#ff0000'
48
+ # Font setting for the application | type=Font
49
+ some_font: 'DejaVuSans.ttf, 12, #0000ff'
50
+ ```
51
+
36
52
  * **Categorized Configuration**: Organize your parameters into logical categories (e.g., `cli`, `app`, `gui`) for better structure and maintainability.
37
53
  * **Dynamic CLI Generation**: Automatically generate `argparse`-compatible command-line arguments directly from your defined configuration parameters, including help texts, types, and choices.
38
54
  * **Config File Management**: Easily load and save configurations from/to YAML or JSON files, allowing users to customize default settings.
39
55
  * **GUI Settings Dialogs**: Dynamically create Tkinter-based settings dialogs for your application, allowing users to intuitively modify configuration parameters via a graphical interface.
56
+
57
+ ![settings_dlg.png](_static/img/settings_dlg.png)
58
+
40
59
  * **Documentation Generation**: Generate detailed Markdown documentation for both your CLI options and all configuration parameters, keeping your user guides always up-to-date with your codebase.
60
+
61
+ ![settings_doc.png](_static/img/settings_doc.png)
62
+
41
63
  * **Override System**: Supports robust overriding of configuration values via configuration files and command-line arguments, with clear precedence.
42
64
 
43
65
  ---
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
28
28
  commit_id: COMMIT_ID
29
29
  __commit_id__: COMMIT_ID
30
30
 
31
- __version__ = version = '0.2.10'
32
- __version_tuple__ = version_tuple = (0, 2, 10)
31
+ __version__ = version = '0.3.1'
32
+ __version_tuple__ = version_tuple = (0, 3, 1)
33
33
 
34
- __commit_id__ = commit_id = 'g50c7157ad'
34
+ __commit_id__ = commit_id = 'g32c96636f'
@@ -4,6 +4,7 @@
4
4
  import argparse
5
5
  import traceback
6
6
  from collections.abc import Callable
7
+ from logging import Logger, getLogger
7
8
  from typing import Any
8
9
 
9
10
  from config_cli_gui.config import ConfigManager
@@ -61,7 +62,7 @@ class CliGenerator:
61
62
  continue
62
63
 
63
64
  # OPTIONAL FLAG
64
- kwargs = {
65
+ kwargs: dict[str, Any] = {
65
66
  "help": f"{p.help} (default: {p.value})",
66
67
  "default": argparse.SUPPRESS,
67
68
  }
@@ -103,16 +104,20 @@ class CliGenerator:
103
104
  # ----------------------------------------------------------------------
104
105
  def run_cli(
105
106
  self,
106
- main_function: Callable[[ConfigManager], int],
107
+ main_function: Callable[[ConfigManager, Logger], int],
107
108
  description: str = None,
108
- validator: Callable[[ConfigManager], bool] = None,
109
+ validator: Callable[[ConfigManager, Logger], bool] = None,
110
+ logger: Logger = None,
109
111
  ) -> int:
110
112
  parser = self.create_argument_parser(description)
111
113
  args = parser.parse_args()
112
114
 
115
+ if logger is None:
116
+ logger = getLogger(self.app_name)
117
+
113
118
  # Load config_file only ONCE
114
119
  config = ConfigManager(
115
- categories=tuple(self.config_manager._categories.values()),
120
+ categories=self.config_manager.get_categories(),
116
121
  config_file=getattr(args, "config", None),
117
122
  )
118
123
 
@@ -121,17 +126,17 @@ class CliGenerator:
121
126
  config.apply_overrides(overrides)
122
127
 
123
128
  # Optional validation
124
- if validator and not validator(config):
125
- print("Configuration validation failed.")
129
+ if validator and not validator(config, logger):
130
+ logger.error("Configuration validation failed.")
126
131
  return 1
127
132
 
128
133
  # Execute main
129
134
  try:
130
- return main_function(config)
135
+ return main_function(config, logger)
131
136
  except KeyboardInterrupt:
132
- print("Interrupted.")
137
+ logger.info("Interrupted.")
133
138
  return 130
134
139
  except Exception as e:
135
- print(f"Unexpected error: {e}")
136
- traceback.print_exc()
140
+ logger.error(f"Unexpected error: {e}")
141
+ logger.debug(traceback.format_exc())
137
142
  return 1