Skip to content

Commit 2ea7f70

Browse files
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 helper
1 parent 7eae142 commit 2ea7f70

8 files changed

Lines changed: 1549 additions & 1512 deletions

File tree

‎Cargo.lock‎

Lines changed: 21 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "wg-tui"
3-
version = "0.2.1"
3+
version = "0.3.0"
44
edition = "2024"
55
description = "A terminal user interface for managing WireGuard VPN tunnels"
66
repository = "https://github.com/excoffierleonard/wg-tui"
@@ -22,11 +22,7 @@ ratatui = "0.30.0"
2222
shellexpand = "3.1.1"
2323
thiserror = "2.0.18"
2424
which = "8.0.0"
25-
zip = { version = "7.2.0", default-features = false, features = ["deflate"] }
25+
zip = { version = "7.4.0", default-features = false, features = ["deflate"] }
2626

2727
[lints.clippy]
28-
pedantic = { level = "warn", priority = -1 }
29-
cargo = { level = "warn", priority = -1 }
30-
# Transitive dependencies pull in multiple versions of common crates (syn, bitflags, thiserror, etc.)
31-
# which we cannot control directly
32-
multiple_crate_versions = "allow"
28+
pedantic = "warn"

0 commit comments

Comments
 (0)