sshmenuc 1.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.
- sshmenuc-1.1.0/LICENSE +9 -0
- sshmenuc-1.1.0/PKG-INFO +356 -0
- sshmenuc-1.1.0/README.md +336 -0
- sshmenuc-1.1.0/pyproject.toml +28 -0
- sshmenuc-1.1.0/sshmenuc/__init__.py +14 -0
- sshmenuc-1.1.0/sshmenuc/__main__.py +6 -0
- sshmenuc-1.1.0/sshmenuc/core/__init__.py +9 -0
- sshmenuc-1.1.0/sshmenuc/core/base.py +108 -0
- sshmenuc-1.1.0/sshmenuc/core/config.py +146 -0
- sshmenuc-1.1.0/sshmenuc/core/config_editor.py +217 -0
- sshmenuc-1.1.0/sshmenuc/core/launcher.py +196 -0
- sshmenuc-1.1.0/sshmenuc/core/navigation.py +366 -0
- sshmenuc-1.1.0/sshmenuc/json_test.json +28 -0
- sshmenuc-1.1.0/sshmenuc/main.py +24 -0
- sshmenuc-1.1.0/sshmenuc/ui/__init__.py +7 -0
- sshmenuc-1.1.0/sshmenuc/ui/colors.py +46 -0
- sshmenuc-1.1.0/sshmenuc/ui/display.py +112 -0
- sshmenuc-1.1.0/sshmenuc/utils/__init__.py +6 -0
- sshmenuc-1.1.0/sshmenuc/utils/helpers.py +86 -0
sshmenuc-1.1.0/LICENSE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 Michael Meyer
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
sshmenuc-1.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: sshmenuc
|
|
3
|
+
Version: 1.1.0
|
|
4
|
+
Summary: Command line SSH menu and helper utility with cluster support (OO rewrite).
|
|
5
|
+
License: GPLv3
|
|
6
|
+
Author: Davide Isoardi
|
|
7
|
+
Author-email: davide@isoardi.info
|
|
8
|
+
Requires-Python: >=3.9,<4.0
|
|
9
|
+
Classifier: License :: Other/Proprietary License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Requires-Dist: clint (>=0.5.1,<0.6.0)
|
|
17
|
+
Requires-Dist: docker (>=7.1.0,<8.0.0)
|
|
18
|
+
Requires-Dist: readchar (>=0.7,<0.8)
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
21
|
+
# sshmenuc
|
|
22
|
+
|
|
23
|
+
[](https://github.com/disoardi/sshmenuc/actions)
|
|
24
|
+
[](https://github.com/disoardi/sshmenuc/actions)
|
|
25
|
+
[](https://codecov.io/gh/disoardi/sshmenuc)
|
|
26
|
+
[](https://www.python.org/downloads/)
|
|
27
|
+
[](https://www.gnu.org/licenses/gpl-3.0)
|
|
28
|
+
|
|
29
|
+
## Overview
|
|
30
|
+
|
|
31
|
+
sshmenuc is a complete rewrite of the original sshmenu tool, implemented as an objectβoriented Python application. The project has been redesigned around classes and clear separation of concerns to make the codebase easier to extend, maintain and test.
|
|
32
|
+
|
|
33
|
+
## Documentation
|
|
34
|
+
|
|
35
|
+
π **Complete documentation is available at: [https://disoardi.github.io/sshmenuc/](https://disoardi.github.io/sshmenuc/)**
|
|
36
|
+
|
|
37
|
+
- [Installation Guide](https://disoardi.github.io/sshmenuc/installation.html)
|
|
38
|
+
- [Configuration Reference](https://disoardi.github.io/sshmenuc/configuration.html)
|
|
39
|
+
- [Usage Guide](https://disoardi.github.io/sshmenuc/usage.html)
|
|
40
|
+
- [API Documentation](https://disoardi.github.io/sshmenuc/api/core.html)
|
|
41
|
+
- [Contributing](https://disoardi.github.io/sshmenuc/contributing.html)
|
|
42
|
+
|
|
43
|
+
## Description
|
|
44
|
+
|
|
45
|
+
sshmenuc provides an interactive terminal menu to browse, filter and launch SSH (and cloud CLI) connections. It supports nested groups of hosts, perβhost metadata (user, connection type, identity file / certkey) and launching different connection commands (e.g., ssh, gcloud ssh inside Docker).
|
|
46
|
+
|
|
47
|
+
### Key Features
|
|
48
|
+
|
|
49
|
+
- π **Interactive configuration editor** - Add, edit, delete, and rename targets and connections directly from the menu
|
|
50
|
+
- π **Nested host groups** - Organize connections hierarchically
|
|
51
|
+
- π₯οΈ **Multiple connection support** - Launch up to 6 connections in tmux split panes
|
|
52
|
+
- π¨ **Colorized terminal UI** - Clear visual feedback and navigation
|
|
53
|
+
- π **SSH key support** - Per-host identity file configuration
|
|
54
|
+
- π³ **Docker/Cloud CLI** - Support for gcloud ssh and other connection types
|
|
55
|
+
- β
**Comprehensive testing** - 102 tests ensuring reliability
|
|
56
|
+
|
|
57
|
+
**Security Note**: sshmenuc intentionally does NOT store or persist plainβtext passwords. If a password is required, either remember it at runtime or use a secure password manager / SSH keys. Password history or inβapp password storage is not supported by design for security reasons.
|
|
58
|
+
|
|
59
|
+
## Requirements
|
|
60
|
+
|
|
61
|
+
- Python 3.9+
|
|
62
|
+
- Dependencies: readchar, clint, docker
|
|
63
|
+
- These are declared in pyproject.toml for packaging
|
|
64
|
+
|
|
65
|
+
## New Modular Structure
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
sshmenuc/
|
|
69
|
+
βββ __init__.py
|
|
70
|
+
βββ __main__.py # Module entry point
|
|
71
|
+
βββ main.py # Application entry point
|
|
72
|
+
βββ core/ # Core business logic
|
|
73
|
+
β βββ __init__.py
|
|
74
|
+
β βββ base.py # Common base class BaseSSHMenuC
|
|
75
|
+
β βββ config.py # ConnectionManager (CRUD operations)
|
|
76
|
+
β βββ config_editor.py # ConfigEditor (interactive editing)
|
|
77
|
+
β βββ navigation.py # ConnectionNavigator (menu & keyboard)
|
|
78
|
+
β βββ launcher.py # SSHLauncher (tmux & SSH)
|
|
79
|
+
βββ ui/ # User interface
|
|
80
|
+
β βββ __init__.py
|
|
81
|
+
β βββ colors.py # Color management (Colors)
|
|
82
|
+
β βββ display.py # Menu rendering (MenuDisplay)
|
|
83
|
+
βββ utils/ # Common utilities
|
|
84
|
+
βββ __init__.py
|
|
85
|
+
βββ helpers.py # Helper functions
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Common Base Class
|
|
89
|
+
|
|
90
|
+
### `BaseSSHMenuC` (core/base.py)
|
|
91
|
+
|
|
92
|
+
Abstract class providing common functionality to all other classes:
|
|
93
|
+
|
|
94
|
+
- **Configuration management**: Loading, saving, validation
|
|
95
|
+
- **Logging setup**: Base logging system configuration
|
|
96
|
+
- **Utility methods**: Directory creation, data structure validation
|
|
97
|
+
- **Template Method pattern**: Abstract `validate_config()` method to implement
|
|
98
|
+
|
|
99
|
+
#### Shared Functionality:
|
|
100
|
+
- `load_config()`: JSON configuration loading and normalization
|
|
101
|
+
- `save_config()`: Configuration saving
|
|
102
|
+
- `get_config()` / `set_config()`: Configuration getter/setter
|
|
103
|
+
- `has_global_hosts()`: Check for hosts presence in configuration
|
|
104
|
+
- `_create_config_directory()`: Configuration directory creation
|
|
105
|
+
|
|
106
|
+
## Derived Classes
|
|
107
|
+
|
|
108
|
+
### 1. `ConnectionManager` (core/config.py)
|
|
109
|
+
Extends `BaseSSHMenuC` for configuration management:
|
|
110
|
+
- CRUD operations on targets and connections
|
|
111
|
+
- Specific validation for configuration structures
|
|
112
|
+
- Methods to create, modify, delete targets and connections
|
|
113
|
+
|
|
114
|
+
### 2. `ConfigEditor` (core/config_editor.py)
|
|
115
|
+
Interactive configuration editor (uses `ConnectionManager`):
|
|
116
|
+
- Form-based target and connection editing
|
|
117
|
+
- Add, edit, delete, rename operations
|
|
118
|
+
- User-friendly prompts and confirmations
|
|
119
|
+
- Integrated keyboard shortcuts (a/e/d/r keys)
|
|
120
|
+
|
|
121
|
+
### 3. `ConnectionNavigator` (core/navigation.py)
|
|
122
|
+
Extends `BaseSSHMenuC` for menu navigation:
|
|
123
|
+
- Main navigation loop
|
|
124
|
+
- User input handling (arrows, space, enter)
|
|
125
|
+
- Multiple selection with markers
|
|
126
|
+
- Integration with `MenuDisplay` for rendering
|
|
127
|
+
- Integrated `ConfigEditor` for inline editing
|
|
128
|
+
|
|
129
|
+
### 4. `SSHLauncher` (core/launcher.py)
|
|
130
|
+
Standalone class for connection launching:
|
|
131
|
+
- tmux session management (single and multiple)
|
|
132
|
+
- SSH command construction with parameters
|
|
133
|
+
- Session name sanitization
|
|
134
|
+
- Multiple connection launching with split panes
|
|
135
|
+
|
|
136
|
+
## UI Components
|
|
137
|
+
|
|
138
|
+
### `Colors` (ui/colors.py)
|
|
139
|
+
- ANSI color constants definitions
|
|
140
|
+
- Text coloring helper methods
|
|
141
|
+
- Semantic methods (`success()`, `warning()`, `error()`)
|
|
142
|
+
|
|
143
|
+
### `MenuDisplay` (ui/display.py)
|
|
144
|
+
- Table and menu rendering
|
|
145
|
+
- Header, row, footer management
|
|
146
|
+
- Multiple selection and marker support
|
|
147
|
+
- Complete separation of display logic
|
|
148
|
+
|
|
149
|
+
## Utilities
|
|
150
|
+
|
|
151
|
+
### `helpers.py` (utils/helpers.py)
|
|
152
|
+
- Argument parser setup
|
|
153
|
+
- Logging configuration
|
|
154
|
+
- Host entry validation
|
|
155
|
+
- Generic support functions
|
|
156
|
+
|
|
157
|
+
## Installation & Usage
|
|
158
|
+
|
|
159
|
+
### Install (buildable pip package)
|
|
160
|
+
|
|
161
|
+
1. Ensure packaging config is present (pyproject.toml). Dependencies are declared there.
|
|
162
|
+
|
|
163
|
+
2. Install build tooling:
|
|
164
|
+
```bash
|
|
165
|
+
python -m pip install --upgrade build twine
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
3. Build distributions:
|
|
169
|
+
```bash
|
|
170
|
+
python -m build
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
4. Install locally:
|
|
174
|
+
```bash
|
|
175
|
+
# Install built wheel
|
|
176
|
+
python -m pip install dist/sshmenuc-<version>-py3-none-any.whl
|
|
177
|
+
|
|
178
|
+
# Or install in editable mode for development
|
|
179
|
+
python -m pip install -e .
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Development with Poetry
|
|
183
|
+
|
|
184
|
+
1. Install Poetry: https://python-poetry.org/docs/#installation
|
|
185
|
+
|
|
186
|
+
2. Create/install environment and dependencies:
|
|
187
|
+
```bash
|
|
188
|
+
poetry install
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
3. Activate Poetry virtualenv:
|
|
192
|
+
```bash
|
|
193
|
+
poetry shell
|
|
194
|
+
# or run commands without activating:
|
|
195
|
+
poetry run python -m sshmenuc
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Running the Application
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
# As a module (recommended)
|
|
202
|
+
python -m sshmenuc
|
|
203
|
+
|
|
204
|
+
# Direct execution
|
|
205
|
+
python sshmenuc/main.py
|
|
206
|
+
|
|
207
|
+
# With arguments
|
|
208
|
+
python -m sshmenuc -c /path/to/config.json -l debug
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## Refactoring Benefits
|
|
212
|
+
|
|
213
|
+
### 1. **Separation of Concerns**
|
|
214
|
+
- Each class has a specific, well-defined responsibility
|
|
215
|
+
- UI separated from business logic
|
|
216
|
+
- Configuration isolated from navigation
|
|
217
|
+
|
|
218
|
+
### 2. **Reusability**
|
|
219
|
+
- Base class provides common functionality
|
|
220
|
+
- UI components reusable in other contexts
|
|
221
|
+
- SSH launcher usable independently
|
|
222
|
+
|
|
223
|
+
### 3. **Testability**
|
|
224
|
+
- Smaller, focused classes
|
|
225
|
+
- Injectable dependencies
|
|
226
|
+
- Well-defined public methods for unit testing
|
|
227
|
+
|
|
228
|
+
### 4. **Extensibility**
|
|
229
|
+
- Easy to add new connection types
|
|
230
|
+
- Template Method pattern for customizations
|
|
231
|
+
- Modular structure for new features
|
|
232
|
+
|
|
233
|
+
### 5. **Maintainability**
|
|
234
|
+
- Logically organized code
|
|
235
|
+
- Reduced code duplication
|
|
236
|
+
- Clear interfaces between modules
|
|
237
|
+
|
|
238
|
+
## Migration Guide
|
|
239
|
+
|
|
240
|
+
### Using the New Structure:
|
|
241
|
+
|
|
242
|
+
```python
|
|
243
|
+
# Instead of importing everything from one file
|
|
244
|
+
from sshmenuc.core import ConnectionManager, ConnectionNavigator
|
|
245
|
+
from sshmenuc.ui import Colors, MenuDisplay
|
|
246
|
+
from sshmenuc.utils import setup_logging
|
|
247
|
+
|
|
248
|
+
# Create objects with common inheritance
|
|
249
|
+
config_manager = ConnectionManager("config.json")
|
|
250
|
+
navigator = ConnectionNavigator("config.json")
|
|
251
|
+
|
|
252
|
+
# Both inherit from BaseSSHMenuC
|
|
253
|
+
assert isinstance(config_manager, BaseSSHMenuC)
|
|
254
|
+
assert isinstance(navigator, BaseSSHMenuC)
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
### Breaking Changes in v1.1.0
|
|
258
|
+
- Original monolithic `sshmenuc.py` has been removed
|
|
259
|
+
- Entry point is now `main.py` with modular structure
|
|
260
|
+
- All functionality maintained through new class-based architecture
|
|
261
|
+
- Configuration format remains compatible
|
|
262
|
+
|
|
263
|
+
## Testing
|
|
264
|
+
|
|
265
|
+
The project includes comprehensive test coverage:
|
|
266
|
+
|
|
267
|
+
- **102 tests** across all modules
|
|
268
|
+
- **69% code coverage** (targeting 90%+)
|
|
269
|
+
- **CI/CD integration** with GitHub Actions
|
|
270
|
+
- **Multi-version testing** on Python 3.9, 3.10, 3.11, 3.12
|
|
271
|
+
|
|
272
|
+
### Running Tests
|
|
273
|
+
|
|
274
|
+
```bash
|
|
275
|
+
# Run all tests
|
|
276
|
+
poetry run pytest
|
|
277
|
+
|
|
278
|
+
# Run with coverage
|
|
279
|
+
poetry run pytest --cov=sshmenuc --cov-report=html
|
|
280
|
+
|
|
281
|
+
# Run specific test file
|
|
282
|
+
poetry run pytest tests/core/test_navigation.py -v
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### Test Examples
|
|
286
|
+
|
|
287
|
+
```python
|
|
288
|
+
# Base class testing
|
|
289
|
+
def test_base_config_loading():
|
|
290
|
+
manager = ConnectionManager("test_config.json")
|
|
291
|
+
assert manager.validate_config()
|
|
292
|
+
|
|
293
|
+
# Isolated UI component testing
|
|
294
|
+
def test_colors():
|
|
295
|
+
colors = Colors()
|
|
296
|
+
assert colors.success("test").startswith("\033[92m")
|
|
297
|
+
|
|
298
|
+
# Launcher testing with mocks
|
|
299
|
+
def test_ssh_launcher():
|
|
300
|
+
launcher = SSHLauncher("test.com", "user")
|
|
301
|
+
assert launcher.host == "test.com"
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
## Contributing
|
|
305
|
+
|
|
306
|
+
Contributions are welcome. Typical workflow:
|
|
307
|
+
|
|
308
|
+
1. Fork the repository
|
|
309
|
+
2. Create a feature branch:
|
|
310
|
+
```bash
|
|
311
|
+
git checkout -b feature/my-change
|
|
312
|
+
```
|
|
313
|
+
3. Implement changes, add tests and update documentation
|
|
314
|
+
4. Commit and push your branch:
|
|
315
|
+
```bash
|
|
316
|
+
git commit -am "Describe change"
|
|
317
|
+
git push origin feature/my-change
|
|
318
|
+
```
|
|
319
|
+
5. Open a Pull Request against the main repository
|
|
320
|
+
|
|
321
|
+
Please follow the existing code style and include tests for new functionality where appropriate.
|
|
322
|
+
|
|
323
|
+
## License
|
|
324
|
+
|
|
325
|
+
This project is licensed under GPLv3. See the LICENSE file for details.
|
|
326
|
+
|
|
327
|
+
## Project Status
|
|
328
|
+
|
|
329
|
+
**Version 1.1.0** - Production Ready β
|
|
330
|
+
|
|
331
|
+
- β
Complete modular refactoring with OOP design
|
|
332
|
+
- β
Comprehensive test suite (102 tests, 69% coverage)
|
|
333
|
+
- β
Full API documentation with Sphinx
|
|
334
|
+
- β
CI/CD pipeline with GitHub Actions
|
|
335
|
+
- β
Interactive configuration editor
|
|
336
|
+
- β
Python 3.9+ support
|
|
337
|
+
|
|
338
|
+
## Future Enhancements
|
|
339
|
+
|
|
340
|
+
Potential improvements for future versions:
|
|
341
|
+
|
|
342
|
+
1. **Observer pattern for UI events**
|
|
343
|
+
- Decouple UI event handling from business logic
|
|
344
|
+
- Enable plugin-based event listeners
|
|
345
|
+
|
|
346
|
+
2. **Dependency injection framework**
|
|
347
|
+
- Improve testability and flexibility
|
|
348
|
+
- Enable runtime component swapping
|
|
349
|
+
|
|
350
|
+
3. **Enhanced features**
|
|
351
|
+
- SSH connection pooling
|
|
352
|
+
- Session history and favorites
|
|
353
|
+
- Advanced filtering and search
|
|
354
|
+
- Custom key bindings
|
|
355
|
+
|
|
356
|
+
Contributions and suggestions are welcome!
|
sshmenuc-1.1.0/README.md
ADDED
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
# sshmenuc
|
|
2
|
+
|
|
3
|
+
[](https://github.com/disoardi/sshmenuc/actions)
|
|
4
|
+
[](https://github.com/disoardi/sshmenuc/actions)
|
|
5
|
+
[](https://codecov.io/gh/disoardi/sshmenuc)
|
|
6
|
+
[](https://www.python.org/downloads/)
|
|
7
|
+
[](https://www.gnu.org/licenses/gpl-3.0)
|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
sshmenuc is a complete rewrite of the original sshmenu tool, implemented as an objectβoriented Python application. The project has been redesigned around classes and clear separation of concerns to make the codebase easier to extend, maintain and test.
|
|
12
|
+
|
|
13
|
+
## Documentation
|
|
14
|
+
|
|
15
|
+
π **Complete documentation is available at: [https://disoardi.github.io/sshmenuc/](https://disoardi.github.io/sshmenuc/)**
|
|
16
|
+
|
|
17
|
+
- [Installation Guide](https://disoardi.github.io/sshmenuc/installation.html)
|
|
18
|
+
- [Configuration Reference](https://disoardi.github.io/sshmenuc/configuration.html)
|
|
19
|
+
- [Usage Guide](https://disoardi.github.io/sshmenuc/usage.html)
|
|
20
|
+
- [API Documentation](https://disoardi.github.io/sshmenuc/api/core.html)
|
|
21
|
+
- [Contributing](https://disoardi.github.io/sshmenuc/contributing.html)
|
|
22
|
+
|
|
23
|
+
## Description
|
|
24
|
+
|
|
25
|
+
sshmenuc provides an interactive terminal menu to browse, filter and launch SSH (and cloud CLI) connections. It supports nested groups of hosts, perβhost metadata (user, connection type, identity file / certkey) and launching different connection commands (e.g., ssh, gcloud ssh inside Docker).
|
|
26
|
+
|
|
27
|
+
### Key Features
|
|
28
|
+
|
|
29
|
+
- π **Interactive configuration editor** - Add, edit, delete, and rename targets and connections directly from the menu
|
|
30
|
+
- π **Nested host groups** - Organize connections hierarchically
|
|
31
|
+
- π₯οΈ **Multiple connection support** - Launch up to 6 connections in tmux split panes
|
|
32
|
+
- π¨ **Colorized terminal UI** - Clear visual feedback and navigation
|
|
33
|
+
- π **SSH key support** - Per-host identity file configuration
|
|
34
|
+
- π³ **Docker/Cloud CLI** - Support for gcloud ssh and other connection types
|
|
35
|
+
- β
**Comprehensive testing** - 102 tests ensuring reliability
|
|
36
|
+
|
|
37
|
+
**Security Note**: sshmenuc intentionally does NOT store or persist plainβtext passwords. If a password is required, either remember it at runtime or use a secure password manager / SSH keys. Password history or inβapp password storage is not supported by design for security reasons.
|
|
38
|
+
|
|
39
|
+
## Requirements
|
|
40
|
+
|
|
41
|
+
- Python 3.9+
|
|
42
|
+
- Dependencies: readchar, clint, docker
|
|
43
|
+
- These are declared in pyproject.toml for packaging
|
|
44
|
+
|
|
45
|
+
## New Modular Structure
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
sshmenuc/
|
|
49
|
+
βββ __init__.py
|
|
50
|
+
βββ __main__.py # Module entry point
|
|
51
|
+
βββ main.py # Application entry point
|
|
52
|
+
βββ core/ # Core business logic
|
|
53
|
+
β βββ __init__.py
|
|
54
|
+
β βββ base.py # Common base class BaseSSHMenuC
|
|
55
|
+
β βββ config.py # ConnectionManager (CRUD operations)
|
|
56
|
+
β βββ config_editor.py # ConfigEditor (interactive editing)
|
|
57
|
+
β βββ navigation.py # ConnectionNavigator (menu & keyboard)
|
|
58
|
+
β βββ launcher.py # SSHLauncher (tmux & SSH)
|
|
59
|
+
βββ ui/ # User interface
|
|
60
|
+
β βββ __init__.py
|
|
61
|
+
β βββ colors.py # Color management (Colors)
|
|
62
|
+
β βββ display.py # Menu rendering (MenuDisplay)
|
|
63
|
+
βββ utils/ # Common utilities
|
|
64
|
+
βββ __init__.py
|
|
65
|
+
βββ helpers.py # Helper functions
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Common Base Class
|
|
69
|
+
|
|
70
|
+
### `BaseSSHMenuC` (core/base.py)
|
|
71
|
+
|
|
72
|
+
Abstract class providing common functionality to all other classes:
|
|
73
|
+
|
|
74
|
+
- **Configuration management**: Loading, saving, validation
|
|
75
|
+
- **Logging setup**: Base logging system configuration
|
|
76
|
+
- **Utility methods**: Directory creation, data structure validation
|
|
77
|
+
- **Template Method pattern**: Abstract `validate_config()` method to implement
|
|
78
|
+
|
|
79
|
+
#### Shared Functionality:
|
|
80
|
+
- `load_config()`: JSON configuration loading and normalization
|
|
81
|
+
- `save_config()`: Configuration saving
|
|
82
|
+
- `get_config()` / `set_config()`: Configuration getter/setter
|
|
83
|
+
- `has_global_hosts()`: Check for hosts presence in configuration
|
|
84
|
+
- `_create_config_directory()`: Configuration directory creation
|
|
85
|
+
|
|
86
|
+
## Derived Classes
|
|
87
|
+
|
|
88
|
+
### 1. `ConnectionManager` (core/config.py)
|
|
89
|
+
Extends `BaseSSHMenuC` for configuration management:
|
|
90
|
+
- CRUD operations on targets and connections
|
|
91
|
+
- Specific validation for configuration structures
|
|
92
|
+
- Methods to create, modify, delete targets and connections
|
|
93
|
+
|
|
94
|
+
### 2. `ConfigEditor` (core/config_editor.py)
|
|
95
|
+
Interactive configuration editor (uses `ConnectionManager`):
|
|
96
|
+
- Form-based target and connection editing
|
|
97
|
+
- Add, edit, delete, rename operations
|
|
98
|
+
- User-friendly prompts and confirmations
|
|
99
|
+
- Integrated keyboard shortcuts (a/e/d/r keys)
|
|
100
|
+
|
|
101
|
+
### 3. `ConnectionNavigator` (core/navigation.py)
|
|
102
|
+
Extends `BaseSSHMenuC` for menu navigation:
|
|
103
|
+
- Main navigation loop
|
|
104
|
+
- User input handling (arrows, space, enter)
|
|
105
|
+
- Multiple selection with markers
|
|
106
|
+
- Integration with `MenuDisplay` for rendering
|
|
107
|
+
- Integrated `ConfigEditor` for inline editing
|
|
108
|
+
|
|
109
|
+
### 4. `SSHLauncher` (core/launcher.py)
|
|
110
|
+
Standalone class for connection launching:
|
|
111
|
+
- tmux session management (single and multiple)
|
|
112
|
+
- SSH command construction with parameters
|
|
113
|
+
- Session name sanitization
|
|
114
|
+
- Multiple connection launching with split panes
|
|
115
|
+
|
|
116
|
+
## UI Components
|
|
117
|
+
|
|
118
|
+
### `Colors` (ui/colors.py)
|
|
119
|
+
- ANSI color constants definitions
|
|
120
|
+
- Text coloring helper methods
|
|
121
|
+
- Semantic methods (`success()`, `warning()`, `error()`)
|
|
122
|
+
|
|
123
|
+
### `MenuDisplay` (ui/display.py)
|
|
124
|
+
- Table and menu rendering
|
|
125
|
+
- Header, row, footer management
|
|
126
|
+
- Multiple selection and marker support
|
|
127
|
+
- Complete separation of display logic
|
|
128
|
+
|
|
129
|
+
## Utilities
|
|
130
|
+
|
|
131
|
+
### `helpers.py` (utils/helpers.py)
|
|
132
|
+
- Argument parser setup
|
|
133
|
+
- Logging configuration
|
|
134
|
+
- Host entry validation
|
|
135
|
+
- Generic support functions
|
|
136
|
+
|
|
137
|
+
## Installation & Usage
|
|
138
|
+
|
|
139
|
+
### Install (buildable pip package)
|
|
140
|
+
|
|
141
|
+
1. Ensure packaging config is present (pyproject.toml). Dependencies are declared there.
|
|
142
|
+
|
|
143
|
+
2. Install build tooling:
|
|
144
|
+
```bash
|
|
145
|
+
python -m pip install --upgrade build twine
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
3. Build distributions:
|
|
149
|
+
```bash
|
|
150
|
+
python -m build
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
4. Install locally:
|
|
154
|
+
```bash
|
|
155
|
+
# Install built wheel
|
|
156
|
+
python -m pip install dist/sshmenuc-<version>-py3-none-any.whl
|
|
157
|
+
|
|
158
|
+
# Or install in editable mode for development
|
|
159
|
+
python -m pip install -e .
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Development with Poetry
|
|
163
|
+
|
|
164
|
+
1. Install Poetry: https://python-poetry.org/docs/#installation
|
|
165
|
+
|
|
166
|
+
2. Create/install environment and dependencies:
|
|
167
|
+
```bash
|
|
168
|
+
poetry install
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
3. Activate Poetry virtualenv:
|
|
172
|
+
```bash
|
|
173
|
+
poetry shell
|
|
174
|
+
# or run commands without activating:
|
|
175
|
+
poetry run python -m sshmenuc
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Running the Application
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
# As a module (recommended)
|
|
182
|
+
python -m sshmenuc
|
|
183
|
+
|
|
184
|
+
# Direct execution
|
|
185
|
+
python sshmenuc/main.py
|
|
186
|
+
|
|
187
|
+
# With arguments
|
|
188
|
+
python -m sshmenuc -c /path/to/config.json -l debug
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Refactoring Benefits
|
|
192
|
+
|
|
193
|
+
### 1. **Separation of Concerns**
|
|
194
|
+
- Each class has a specific, well-defined responsibility
|
|
195
|
+
- UI separated from business logic
|
|
196
|
+
- Configuration isolated from navigation
|
|
197
|
+
|
|
198
|
+
### 2. **Reusability**
|
|
199
|
+
- Base class provides common functionality
|
|
200
|
+
- UI components reusable in other contexts
|
|
201
|
+
- SSH launcher usable independently
|
|
202
|
+
|
|
203
|
+
### 3. **Testability**
|
|
204
|
+
- Smaller, focused classes
|
|
205
|
+
- Injectable dependencies
|
|
206
|
+
- Well-defined public methods for unit testing
|
|
207
|
+
|
|
208
|
+
### 4. **Extensibility**
|
|
209
|
+
- Easy to add new connection types
|
|
210
|
+
- Template Method pattern for customizations
|
|
211
|
+
- Modular structure for new features
|
|
212
|
+
|
|
213
|
+
### 5. **Maintainability**
|
|
214
|
+
- Logically organized code
|
|
215
|
+
- Reduced code duplication
|
|
216
|
+
- Clear interfaces between modules
|
|
217
|
+
|
|
218
|
+
## Migration Guide
|
|
219
|
+
|
|
220
|
+
### Using the New Structure:
|
|
221
|
+
|
|
222
|
+
```python
|
|
223
|
+
# Instead of importing everything from one file
|
|
224
|
+
from sshmenuc.core import ConnectionManager, ConnectionNavigator
|
|
225
|
+
from sshmenuc.ui import Colors, MenuDisplay
|
|
226
|
+
from sshmenuc.utils import setup_logging
|
|
227
|
+
|
|
228
|
+
# Create objects with common inheritance
|
|
229
|
+
config_manager = ConnectionManager("config.json")
|
|
230
|
+
navigator = ConnectionNavigator("config.json")
|
|
231
|
+
|
|
232
|
+
# Both inherit from BaseSSHMenuC
|
|
233
|
+
assert isinstance(config_manager, BaseSSHMenuC)
|
|
234
|
+
assert isinstance(navigator, BaseSSHMenuC)
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### Breaking Changes in v1.1.0
|
|
238
|
+
- Original monolithic `sshmenuc.py` has been removed
|
|
239
|
+
- Entry point is now `main.py` with modular structure
|
|
240
|
+
- All functionality maintained through new class-based architecture
|
|
241
|
+
- Configuration format remains compatible
|
|
242
|
+
|
|
243
|
+
## Testing
|
|
244
|
+
|
|
245
|
+
The project includes comprehensive test coverage:
|
|
246
|
+
|
|
247
|
+
- **102 tests** across all modules
|
|
248
|
+
- **69% code coverage** (targeting 90%+)
|
|
249
|
+
- **CI/CD integration** with GitHub Actions
|
|
250
|
+
- **Multi-version testing** on Python 3.9, 3.10, 3.11, 3.12
|
|
251
|
+
|
|
252
|
+
### Running Tests
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
# Run all tests
|
|
256
|
+
poetry run pytest
|
|
257
|
+
|
|
258
|
+
# Run with coverage
|
|
259
|
+
poetry run pytest --cov=sshmenuc --cov-report=html
|
|
260
|
+
|
|
261
|
+
# Run specific test file
|
|
262
|
+
poetry run pytest tests/core/test_navigation.py -v
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### Test Examples
|
|
266
|
+
|
|
267
|
+
```python
|
|
268
|
+
# Base class testing
|
|
269
|
+
def test_base_config_loading():
|
|
270
|
+
manager = ConnectionManager("test_config.json")
|
|
271
|
+
assert manager.validate_config()
|
|
272
|
+
|
|
273
|
+
# Isolated UI component testing
|
|
274
|
+
def test_colors():
|
|
275
|
+
colors = Colors()
|
|
276
|
+
assert colors.success("test").startswith("\033[92m")
|
|
277
|
+
|
|
278
|
+
# Launcher testing with mocks
|
|
279
|
+
def test_ssh_launcher():
|
|
280
|
+
launcher = SSHLauncher("test.com", "user")
|
|
281
|
+
assert launcher.host == "test.com"
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
## Contributing
|
|
285
|
+
|
|
286
|
+
Contributions are welcome. Typical workflow:
|
|
287
|
+
|
|
288
|
+
1. Fork the repository
|
|
289
|
+
2. Create a feature branch:
|
|
290
|
+
```bash
|
|
291
|
+
git checkout -b feature/my-change
|
|
292
|
+
```
|
|
293
|
+
3. Implement changes, add tests and update documentation
|
|
294
|
+
4. Commit and push your branch:
|
|
295
|
+
```bash
|
|
296
|
+
git commit -am "Describe change"
|
|
297
|
+
git push origin feature/my-change
|
|
298
|
+
```
|
|
299
|
+
5. Open a Pull Request against the main repository
|
|
300
|
+
|
|
301
|
+
Please follow the existing code style and include tests for new functionality where appropriate.
|
|
302
|
+
|
|
303
|
+
## License
|
|
304
|
+
|
|
305
|
+
This project is licensed under GPLv3. See the LICENSE file for details.
|
|
306
|
+
|
|
307
|
+
## Project Status
|
|
308
|
+
|
|
309
|
+
**Version 1.1.0** - Production Ready β
|
|
310
|
+
|
|
311
|
+
- β
Complete modular refactoring with OOP design
|
|
312
|
+
- β
Comprehensive test suite (102 tests, 69% coverage)
|
|
313
|
+
- β
Full API documentation with Sphinx
|
|
314
|
+
- β
CI/CD pipeline with GitHub Actions
|
|
315
|
+
- β
Interactive configuration editor
|
|
316
|
+
- β
Python 3.9+ support
|
|
317
|
+
|
|
318
|
+
## Future Enhancements
|
|
319
|
+
|
|
320
|
+
Potential improvements for future versions:
|
|
321
|
+
|
|
322
|
+
1. **Observer pattern for UI events**
|
|
323
|
+
- Decouple UI event handling from business logic
|
|
324
|
+
- Enable plugin-based event listeners
|
|
325
|
+
|
|
326
|
+
2. **Dependency injection framework**
|
|
327
|
+
- Improve testability and flexibility
|
|
328
|
+
- Enable runtime component swapping
|
|
329
|
+
|
|
330
|
+
3. **Enhanced features**
|
|
331
|
+
- SSH connection pooling
|
|
332
|
+
- Session history and favorites
|
|
333
|
+
- Advanced filtering and search
|
|
334
|
+
- Custom key bindings
|
|
335
|
+
|
|
336
|
+
Contributions and suggestions are welcome!
|