Repository navigation
Commit 2ea7f70
committed
refactor: clean up and professionalize the codebase
Structured error handling:
- Replace catch-all Error::WgTui(String) with 7 typed variants:
InvalidInterfaceName, TunnelAlreadyExists, Config, CommandFailed,
Validation, Import, NoTunnelsToExport
- Migrate all 27 call sites in wireguard.rs to appropriate variants
DRY config parsing:
- Extract WgConfig parser struct with parse(), interface_value(),
all_values(), interface_has_any_key() to replace 4 functions that
duplicated INI-section parsing boilerplate
- Optimize add_server_peer() to parse config once instead of 5 times
Stronger path types:
- Change import_tunnel, import_zip_conflict_count, import_tunnels,
export_tunnels_to_zip from &str to &Path parameters
- Move expand_path() calls to call sites in app layer
- Extract open_conf_archive() helper to deduplicate zip validation
Split monolithic app.rs (1412 lines) into focused modules:
- app.rs: App struct, AppFlags bitfield, core state management
- app/input.rs: event handling, all consume_* handlers
- app/render.rs: draw() and all render_* methods
- app/wizard.rs: wizard types and supporting structs
Consolidate duplicated patterns:
- Extract InputAction enum + handle_text_input() helper to eliminate
7x duplicated Backspace/Char/Esc match arms across input handlers
- Define WizardSteps trait implemented by both Client and Server
wizards, replacing manual 5-method delegation
- Add NewTunnelWizard::create() to collapse duplicated completion
branches from 24 lines to 8
- Unify interface name validation into single shared helper1 parent 7eae142 commit 2ea7f70
8 files changed
Lines changed: 1549 additions & 1512 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
| 28 | + | |
0 commit comments