cfgcommander 0.1.0__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 (45) hide show
  1. cfgcommander-0.1.0/.gitignore +30 -0
  2. cfgcommander-0.1.0/LICENSE +202 -0
  3. cfgcommander-0.1.0/NOTICE +2 -0
  4. cfgcommander-0.1.0/PKG-INFO +189 -0
  5. cfgcommander-0.1.0/README.md +153 -0
  6. cfgcommander-0.1.0/examples/demo.ini +23 -0
  7. cfgcommander-0.1.0/examples/demo.json +27 -0
  8. cfgcommander-0.1.0/examples/demo.schema.json +46 -0
  9. cfgcommander-0.1.0/examples/demo.toml +51 -0
  10. cfgcommander-0.1.0/examples/demo.yaml +36 -0
  11. cfgcommander-0.1.0/pyproject.toml +58 -0
  12. cfgcommander-0.1.0/samples/backup.yml +21 -0
  13. cfgcommander-0.1.0/samples/compose.yaml +30 -0
  14. cfgcommander-0.1.0/samples/database.ini +17 -0
  15. cfgcommander-0.1.0/samples/editor.json +23 -0
  16. cfgcommander-0.1.0/samples/game.toml +35 -0
  17. cfgcommander-0.1.0/samples/settings +11 -0
  18. cfgcommander-0.1.0/samples/sync.conf +15 -0
  19. cfgcommander-0.1.0/samples/webserver.schema.json +44 -0
  20. cfgcommander-0.1.0/samples/webserver.toml +45 -0
  21. cfgcommander-0.1.0/scripts/build_binary.py +62 -0
  22. cfgcommander-0.1.0/scripts/build_pyz.py +70 -0
  23. cfgcommander-0.1.0/src/cfgcommander/__init__.py +19 -0
  24. cfgcommander-0.1.0/src/cfgcommander/__main__.py +5 -0
  25. cfgcommander-0.1.0/src/cfgcommander/cli.py +55 -0
  26. cfgcommander-0.1.0/src/cfgcommander/fields.py +215 -0
  27. cfgcommander-0.1.0/src/cfgcommander/formats/__init__.py +61 -0
  28. cfgcommander-0.1.0/src/cfgcommander/formats/base.py +45 -0
  29. cfgcommander-0.1.0/src/cfgcommander/formats/inifmt.py +190 -0
  30. cfgcommander-0.1.0/src/cfgcommander/formats/jsonfmt.py +133 -0
  31. cfgcommander-0.1.0/src/cfgcommander/formats/tomlfmt.py +99 -0
  32. cfgcommander-0.1.0/src/cfgcommander/formats/yamlfmt.py +100 -0
  33. cfgcommander-0.1.0/src/cfgcommander/model.py +401 -0
  34. cfgcommander-0.1.0/src/cfgcommander/schema.py +147 -0
  35. cfgcommander-0.1.0/src/cfgcommander/ui/__init__.py +1 -0
  36. cfgcommander-0.1.0/src/cfgcommander/ui/app.py +155 -0
  37. cfgcommander-0.1.0/src/cfgcommander/ui/commander.tcss +603 -0
  38. cfgcommander-0.1.0/src/cfgcommander/ui/editors.py +229 -0
  39. cfgcommander-0.1.0/src/cfgcommander/ui/panes.py +348 -0
  40. cfgcommander-0.1.0/src/cfgcommander/ui/screens.py +196 -0
  41. cfgcommander-0.1.0/tests/conftest.py +22 -0
  42. cfgcommander-0.1.0/tests/test_detect.py +71 -0
  43. cfgcommander-0.1.0/tests/test_roundtrip.py +327 -0
  44. cfgcommander-0.1.0/tests/test_schema.py +113 -0
  45. cfgcommander-0.1.0/tests/test_ui.py +341 -0
@@ -0,0 +1,30 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ .venv/
6
+ venv/
7
+
8
+ # Build output
9
+ build/
10
+ dist/
11
+ release/
12
+ *.spec
13
+
14
+ # Tests and tools
15
+ .pytest_cache/
16
+ .coverage
17
+ htmlcov/
18
+ .mypy_cache/
19
+ .ruff_cache/
20
+
21
+ # Textual debug output (TEXTUAL_DEBUG=1)
22
+ keys.log
23
+ textual.log
24
+
25
+ # Local
26
+ resume.sh
27
+ .claude/
28
+ .DS_Store
29
+ .idea/
30
+ .vscode/
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,2 @@
1
+ cfgcommander
2
+ Copyright 2026 sha0coder
@@ -0,0 +1,189 @@
1
+ Metadata-Version: 2.5
2
+ Name: cfgcommander
3
+ Version: 0.1.0
4
+ Summary: Retro DOS file-commander style TUI that builds itself at runtime from a TOML/JSON/YAML/INI config file
5
+ Project-URL: Homepage, https://github.com/sha0coder/cfgcommander
6
+ Project-URL: Repository, https://github.com/sha0coder/cfgcommander
7
+ Project-URL: Issues, https://github.com/sha0coder/cfgcommander/issues
8
+ Author: sha0coder
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE
11
+ License-File: NOTICE
12
+ Keywords: config,ini,json,textual,toml,tui,yaml
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Environment :: Console
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: System Administrators
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3 :: Only
20
+ Classifier: Programming Language :: Python :: 3.9
21
+ Classifier: Programming Language :: Python :: 3.10
22
+ Classifier: Programming Language :: Python :: 3.11
23
+ Classifier: Programming Language :: Python :: 3.12
24
+ Classifier: Programming Language :: Python :: 3.13
25
+ Classifier: Programming Language :: Python :: 3.14
26
+ Classifier: Topic :: System :: Systems Administration
27
+ Classifier: Topic :: Utilities
28
+ Requires-Python: >=3.9
29
+ Requires-Dist: ruamel-yaml>=0.18
30
+ Requires-Dist: textual>=8.0
31
+ Requires-Dist: tomlkit>=0.13
32
+ Provides-Extra: dev
33
+ Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
34
+ Requires-Dist: pytest>=8; extra == 'dev'
35
+ Description-Content-Type: text/markdown
36
+
37
+ # cfgcommander
38
+
39
+ A Norton Commander style TUI that edits a config file. The interface is not
40
+ written per file: it is generated at runtime from the parsed tree, for **TOML,
41
+ JSON, YAML and INI**, and saves back in the original format keeping comments
42
+ and key order.
43
+
44
+ ```
45
+ cfgcommander │ examples/demo.toml │ TOML │ schema │ ● modified
46
+ General server database users
47
+ ╔══════════════════════════════ server ═══════════════════════════════╗
48
+ ║ host 127.0.0.1 ║
49
+ ║ port 8080 1..65535 TCP port ║
50
+ ║ log_level info ▼ ║
51
+ ║ mode ( ) development ( ) staging (•) production ║
52
+ ║ tags ► […] web, edge, blue ║
53
+ ║ tls ► {…} 3 keys ║
54
+ ╚═════════════════════════════════════════════════════════════════════╝
55
+ F2 Save F9 Menu F10 Quit Esc Back
56
+ ```
57
+
58
+ ## Install
59
+
60
+ ```sh
61
+ pipx install cfgcommander # or: uv tool install cfgcommander
62
+ cfgcommander config.toml
63
+ ```
64
+
65
+ From a checkout: `pipx install .` and try
66
+ `cfgcommander examples/demo.toml --schema examples/demo.schema.json`.
67
+
68
+ For development:
69
+
70
+ ```sh
71
+ python -m venv .venv && .venv/bin/pip install -e '.[dev]'
72
+ .venv/bin/pytest
73
+ ```
74
+
75
+ ## Single file, no venv
76
+
77
+ ```sh
78
+ python3 scripts/build_pyz.py # writes release/cfgcommander.pyz (~3 MB)
79
+ python3 release/cfgcommander.pyz config.toml
80
+ ```
81
+
82
+ `cfgcommander.pyz` is one file with the app and every dependency inside. It needs
83
+ only Python 3.9+ (the `python3` that ships with macOS is enough), no venv and no
84
+ install: copy it anywhere, `chmod +x` it and put it on your `PATH` if you like.
85
+ All bundled code is pure Python, so the same file runs on macOS, Linux and
86
+ Windows.
87
+
88
+ ### Standalone executable
89
+
90
+ ```sh
91
+ pip install pyinstaller
92
+ python3 scripts/build_binary.py # writes release/cfgcommander-<os>-<arch> (~15 MB)
93
+ ```
94
+
95
+ Runs on machines without Python, but only on the operating system and CPU
96
+ architecture it was built on.
97
+
98
+ ## Usage
99
+
100
+ ```
101
+ cfgcommander FILE [--schema SCHEMA.json] [--format toml|json|yaml|ini]
102
+ ```
103
+
104
+ The format is detected from the extension (`.toml`, `.json`, `.yaml`/`.yml`,
105
+ `.ini`/`.cfg`/`.conf`). If the extension is unknown, or the content does not
106
+ parse as that format, the content is tried as JSON, TOML, INI and YAML in that
107
+ order. `--format` skips detection.
108
+
109
+ ### How the tree becomes a UI
110
+
111
+ | In the file | In the UI |
112
+ |-------------------------------------|--------------------------------------------------------|
113
+ | top-level table | a tab in the menu bar |
114
+ | top-level scalars | the `General` tab |
115
+ | nested table | a `► {…}` link that opens a window |
116
+ | bool | checkbox `[x]` |
117
+ | integer / float | input with a numeric validator |
118
+ | string | input (text area if it contains line breaks) |
119
+ | date / time (TOML, YAML) | input validated as ISO 8601, saved as a date again |
120
+ | array | editable list: add, delete, reorder |
121
+ | array of tables (`[[x]]` in TOML) | list (one row per table) → detail window |
122
+ | schema `enum`, up to 4 short options| radio buttons |
123
+ | schema `enum`, more options | drop-down |
124
+ | schema `minimum` / `maximum` / exclusive bounds | range check, shown next to the field |
125
+
126
+ ### Keys
127
+
128
+ | Key | Action |
129
+ |----------------|---------------------------------------------------------|
130
+ | `F2`, `Ctrl+S` | save |
131
+ | `F9` | menu bar (then `←` `→`, `Enter`/`↓` to go into the tab) |
132
+ | `F10` | quit (asks if there are unsaved changes) |
133
+ | `Esc` | back: close the window / dialog, or go to the menu bar |
134
+ | `↑` `↓`, `Tab` | move between fields |
135
+ | `Enter` | open a nested table, a list item, or a drop-down |
136
+ | `F4` | edit the selected list item |
137
+ | `F5` / `F6` | move the selected list item up / down |
138
+ | `F7` / `F8` | add / delete a list item |
139
+
140
+ A field whose text is not valid turns red, shows why, and keeps its previous
141
+ value in the document until the text is valid again.
142
+
143
+ ## What is preserved on save
144
+
145
+ * **TOML** (tomlkit): comments, blank lines, key order, table layout.
146
+ * **YAML** (ruamel.yaml): comments, key order, quoting style, indentation
147
+ (detected from the file). ruamel keeps an end-of-line comment at its column
148
+ when the new value fits, and one space after the value when it does not.
149
+ * **INI** (configparser): `configparser` discards comments when it writes, so it
150
+ is used to parse and to verify, and saving rewrites only the value part of
151
+ the lines that changed. Comments, blank lines, `=` vs `:` and the spelling of
152
+ booleans (`yes`/`no`, `On`/`Off`, …) stay as they were. Values are shown as
153
+ bool / int / float when they look like one.
154
+ * **JSON** (stdlib): key order, indent width, and which objects/arrays were
155
+ written on a single line. JSON has no comments.
156
+
157
+ A file that is opened and saved without edits is byte-for-byte identical, and
158
+ CRLF line endings are kept. Saving is atomic (temp file + rename).
159
+
160
+ Limits worth knowing: keys cannot be added to or removed from tables (only
161
+ array items can); in TOML and YAML a comment written on the line *above* an
162
+ array item stays at that position when items are reordered; and once a JSON
163
+ file has been edited, saving normalises its number literals (`1e3` is written
164
+ back as `1000.0`).
165
+
166
+ ## JSON Schema (`--schema`)
167
+
168
+ Optional. Only the parts that affect editing are used: `enum`/`const`,
169
+ `minimum`, `maximum`, `exclusiveMinimum`, `exclusiveMaximum` (number and
170
+ draft-04 boolean forms), `type`, `default`, `description`/`title`, navigated
171
+ through `properties`, `patternProperties`, `additionalProperties`, `items`,
172
+ `prefixItems`, local `$ref`, `allOf` and "X or null" `anyOf`/`oneOf`. Remote
173
+ `$ref`s are ignored. `default` and the first `enum` option are used to fill new
174
+ list items.
175
+
176
+ ## Layout
177
+
178
+ ```
179
+ src/cfgcommander/
180
+ fields.py value kinds, parsing and validation of one field
181
+ schema.py JSON Schema navigation
182
+ model.py ConfigModel: the editable tree (get/set/append/delete/move/save)
183
+ formats/ one backend per format + detection
184
+ ui/ Textual front end (app, panes, screens, editors)
185
+ ui/commander.tcss every colour, border and shadow
186
+ tests/ round trips per format, detection, schema, and the TUI via pilot
187
+ ```
188
+
189
+ The model has no Textual imports; the UI only talks to `ConfigModel`.
@@ -0,0 +1,153 @@
1
+ # cfgcommander
2
+
3
+ A Norton Commander style TUI that edits a config file. The interface is not
4
+ written per file: it is generated at runtime from the parsed tree, for **TOML,
5
+ JSON, YAML and INI**, and saves back in the original format keeping comments
6
+ and key order.
7
+
8
+ ```
9
+ cfgcommander │ examples/demo.toml │ TOML │ schema │ ● modified
10
+ General server database users
11
+ ╔══════════════════════════════ server ═══════════════════════════════╗
12
+ ║ host 127.0.0.1 ║
13
+ ║ port 8080 1..65535 TCP port ║
14
+ ║ log_level info ▼ ║
15
+ ║ mode ( ) development ( ) staging (•) production ║
16
+ ║ tags ► […] web, edge, blue ║
17
+ ║ tls ► {…} 3 keys ║
18
+ ╚═════════════════════════════════════════════════════════════════════╝
19
+ F2 Save F9 Menu F10 Quit Esc Back
20
+ ```
21
+
22
+ ## Install
23
+
24
+ ```sh
25
+ pipx install cfgcommander # or: uv tool install cfgcommander
26
+ cfgcommander config.toml
27
+ ```
28
+
29
+ From a checkout: `pipx install .` and try
30
+ `cfgcommander examples/demo.toml --schema examples/demo.schema.json`.
31
+
32
+ For development:
33
+
34
+ ```sh
35
+ python -m venv .venv && .venv/bin/pip install -e '.[dev]'
36
+ .venv/bin/pytest
37
+ ```
38
+
39
+ ## Single file, no venv
40
+
41
+ ```sh
42
+ python3 scripts/build_pyz.py # writes release/cfgcommander.pyz (~3 MB)
43
+ python3 release/cfgcommander.pyz config.toml
44
+ ```
45
+
46
+ `cfgcommander.pyz` is one file with the app and every dependency inside. It needs
47
+ only Python 3.9+ (the `python3` that ships with macOS is enough), no venv and no
48
+ install: copy it anywhere, `chmod +x` it and put it on your `PATH` if you like.
49
+ All bundled code is pure Python, so the same file runs on macOS, Linux and
50
+ Windows.
51
+
52
+ ### Standalone executable
53
+
54
+ ```sh
55
+ pip install pyinstaller
56
+ python3 scripts/build_binary.py # writes release/cfgcommander-<os>-<arch> (~15 MB)
57
+ ```
58
+
59
+ Runs on machines without Python, but only on the operating system and CPU
60
+ architecture it was built on.
61
+
62
+ ## Usage
63
+
64
+ ```
65
+ cfgcommander FILE [--schema SCHEMA.json] [--format toml|json|yaml|ini]
66
+ ```
67
+
68
+ The format is detected from the extension (`.toml`, `.json`, `.yaml`/`.yml`,
69
+ `.ini`/`.cfg`/`.conf`). If the extension is unknown, or the content does not
70
+ parse as that format, the content is tried as JSON, TOML, INI and YAML in that
71
+ order. `--format` skips detection.
72
+
73
+ ### How the tree becomes a UI
74
+
75
+ | In the file | In the UI |
76
+ |-------------------------------------|--------------------------------------------------------|
77
+ | top-level table | a tab in the menu bar |
78
+ | top-level scalars | the `General` tab |
79
+ | nested table | a `► {…}` link that opens a window |
80
+ | bool | checkbox `[x]` |
81
+ | integer / float | input with a numeric validator |
82
+ | string | input (text area if it contains line breaks) |
83
+ | date / time (TOML, YAML) | input validated as ISO 8601, saved as a date again |
84
+ | array | editable list: add, delete, reorder |
85
+ | array of tables (`[[x]]` in TOML) | list (one row per table) → detail window |
86
+ | schema `enum`, up to 4 short options| radio buttons |
87
+ | schema `enum`, more options | drop-down |
88
+ | schema `minimum` / `maximum` / exclusive bounds | range check, shown next to the field |
89
+
90
+ ### Keys
91
+
92
+ | Key | Action |
93
+ |----------------|---------------------------------------------------------|
94
+ | `F2`, `Ctrl+S` | save |
95
+ | `F9` | menu bar (then `←` `→`, `Enter`/`↓` to go into the tab) |
96
+ | `F10` | quit (asks if there are unsaved changes) |
97
+ | `Esc` | back: close the window / dialog, or go to the menu bar |
98
+ | `↑` `↓`, `Tab` | move between fields |
99
+ | `Enter` | open a nested table, a list item, or a drop-down |
100
+ | `F4` | edit the selected list item |
101
+ | `F5` / `F6` | move the selected list item up / down |
102
+ | `F7` / `F8` | add / delete a list item |
103
+
104
+ A field whose text is not valid turns red, shows why, and keeps its previous
105
+ value in the document until the text is valid again.
106
+
107
+ ## What is preserved on save
108
+
109
+ * **TOML** (tomlkit): comments, blank lines, key order, table layout.
110
+ * **YAML** (ruamel.yaml): comments, key order, quoting style, indentation
111
+ (detected from the file). ruamel keeps an end-of-line comment at its column
112
+ when the new value fits, and one space after the value when it does not.
113
+ * **INI** (configparser): `configparser` discards comments when it writes, so it
114
+ is used to parse and to verify, and saving rewrites only the value part of
115
+ the lines that changed. Comments, blank lines, `=` vs `:` and the spelling of
116
+ booleans (`yes`/`no`, `On`/`Off`, …) stay as they were. Values are shown as
117
+ bool / int / float when they look like one.
118
+ * **JSON** (stdlib): key order, indent width, and which objects/arrays were
119
+ written on a single line. JSON has no comments.
120
+
121
+ A file that is opened and saved without edits is byte-for-byte identical, and
122
+ CRLF line endings are kept. Saving is atomic (temp file + rename).
123
+
124
+ Limits worth knowing: keys cannot be added to or removed from tables (only
125
+ array items can); in TOML and YAML a comment written on the line *above* an
126
+ array item stays at that position when items are reordered; and once a JSON
127
+ file has been edited, saving normalises its number literals (`1e3` is written
128
+ back as `1000.0`).
129
+
130
+ ## JSON Schema (`--schema`)
131
+
132
+ Optional. Only the parts that affect editing are used: `enum`/`const`,
133
+ `minimum`, `maximum`, `exclusiveMinimum`, `exclusiveMaximum` (number and
134
+ draft-04 boolean forms), `type`, `default`, `description`/`title`, navigated
135
+ through `properties`, `patternProperties`, `additionalProperties`, `items`,
136
+ `prefixItems`, local `$ref`, `allOf` and "X or null" `anyOf`/`oneOf`. Remote
137
+ `$ref`s are ignored. `default` and the first `enum` option are used to fill new
138
+ list items.
139
+
140
+ ## Layout
141
+
142
+ ```
143
+ src/cfgcommander/
144
+ fields.py value kinds, parsing and validation of one field
145
+ schema.py JSON Schema navigation
146
+ model.py ConfigModel: the editable tree (get/set/append/delete/move/save)
147
+ formats/ one backend per format + detection
148
+ ui/ Textual front end (app, panes, screens, editors)
149
+ ui/commander.tcss every colour, border and shadow
150
+ tests/ round trips per format, detection, schema, and the TUI via pilot
151
+ ```
152
+
153
+ The model has no Textual imports; the UI only talks to `ConfigModel`.
@@ -0,0 +1,23 @@
1
+ ; Demo configuration for cfgcommander
2
+
3
+ [server]
4
+ host = 127.0.0.1
5
+ # 1-65535
6
+ port = 8080
7
+ workers = 4
8
+ timeout = 2.5
9
+ log_level = info
10
+ mode = production
11
+
12
+ [tls]
13
+ enabled = yes
14
+ cert: /etc/ssl/cert.pem
15
+ min_version = 1.2
16
+
17
+ ; database settings
18
+ [database]
19
+ url = postgres://localhost/demo
20
+ pool_size = 10
21
+ echo = Off
22
+ motd = first line
23
+ second line
@@ -0,0 +1,27 @@
1
+ {
2
+ "title": "Demo server",
3
+ "debug": false,
4
+ "server": {
5
+ "host": "127.0.0.1",
6
+ "port": 8080,
7
+ "workers": 4,
8
+ "timeout": 2.5,
9
+ "log_level": "info",
10
+ "mode": "production",
11
+ "tags": ["web", "edge", "blue"],
12
+ "tls": {
13
+ "enabled": true,
14
+ "cert": "/etc/ssl/cert.pem",
15
+ "min_version": "1.2"
16
+ }
17
+ },
18
+ "database": {
19
+ "url": "postgres://localhost/demo",
20
+ "pool_size": 10,
21
+ "echo": false
22
+ },
23
+ "users": [
24
+ {"name": "alice", "role": "admin", "active": true, "quota": 100},
25
+ {"name": "bob", "role": "editor", "active": false, "quota": 20}
26
+ ]
27
+ }