Repository: fujiapple852/trippy (language: rust)

Issue:
`tui-address-mode` does not accept `ip`
**Describe the bug**
<!-- A description of what the bug is. -->

Instead of `tui-address-mode` accepting `ip` as a valid value it expects `i-p`.

```
trip 8.8.8.8
Error: TOML parse error at line 243, column 20
    |
243 | tui-address-mode = "ip"
    |                    ^^^^
unknown variant `ip`, expected one of `i-p`, `host`, `both`
```


**To Reproduce**
<!-- A description of the steps to reproduce the behavior including the full `trip` or `trip.exe` command line. -->

 - Create a config file using `trip --print-config-template > trippy.toml`
 - Then edit `tui-address-mode` to be `ip`.
 - Then run trippy `trip 8.8.8.8`

**Expected behavior**
<!-- A description of what you expected to happen. -->

Expected mode to be set to `ip` with trip running


**Environment Info**
- OS: <!-- e.g. Linux, Windows 11, MacOS --> Ubuntu
- Trippy version: <!-- the output of `trip -V` --> trip 0.11.0
- Installation method: <!-- e.g. `brew`, `winget`, `cargo` --> cargo
- Terminal / Console: <!-- If you are not sure you can use "About" or, "Help" on the terminal window to gather the requested information. e.g. `iterm2`, `cmd.exe`, `PowerShell`, 'GNOME Terminal' --> GNOME Terminal - Version 3.44.0 for GNOME 42



Discussion / hints:

Fix patch:
diff --git a/crates/trippy-tui/src/config.rs b/crates/trippy-tui/src/config.rs
index c62850040..ca700bcf5 100644
--- a/crates/trippy-tui/src/config.rs
+++ b/crates/trippy-tui/src/config.rs
@@ -127,7 +127,7 @@ impl From<MultipathStrategy> for MultipathStrategyConfig {
 #[serde(rename_all = "kebab-case")]
 pub enum AddressMode {
     /// Show IP address only.
-    IP,
+    Ip,
     /// Show reverse-lookup DNS hostname only.
     Host,
     /// Show both IP address and reverse-lookup DNS hostname.
@@ -1476,7 +1476,7 @@ mod tests {
     }
 
     #[test_case("trip example.com", Ok(cfg().tui_address_mode(AddressMode::Host).build()); "default tui address mode")]
-    #[test_case("trip example.com --tui-address-mode ip", Ok(cfg().tui_address_mode(AddressMode::IP).build()); "ip tui address mode")]
+    #[test_case("trip example.com --tui-address-mode ip", Ok(cfg().tui_address_mode(AddressMode::Ip).build()); "ip tui address mode")]
     #[test_case("trip example.com --tui-address-mode host", Ok(cfg().tui_address_mode(AddressMode::Host).build()); "host tui address mode")]
     #[test_case("trip example.com --tui-address-mode both", Ok(cfg().tui_address_mode(AddressMode::Both).build()); "both tui address mode")]
     #[test_case("trip example.com -a both", Ok(cfg().tui_address_mode(AddressMode::Both).build()); "custom tui address mode short")]
diff --git a/crates/trippy-tui/src/frontend.rs b/crates/trippy-tui/src/frontend.rs
index 8bce829ec..4d1f4e3c3 100644
--- a/crates/trippy-tui/src/frontend.rs
+++ b/crates/trippy-tui/src/frontend.rs
@@ -182,7 +182,7 @@ fn run_app<B: Backend>(
                     } else if bindings.previous_hop_address.check(key) {
                         app.previous_hop_address();
                     } else if bindings.address_mode_ip.check(key) {
-                        app.tui_config.address_mode = AddressMode::IP;
+                        app.tui_config.address_mode = AddressMode::Ip;
                     } else if bindings.address_mode_host.check(key) {
                         app.tui_config.address_mode = AddressMode::Host;
                     } else if bindings.address_mode_both.check(key) {
diff --git a/crates/trippy-tui/src/frontend/render/settings.rs b/crates/trippy-tui/src/frontend/render/settings.rs
index 297402e77..1f3edd447 100644
--- a/crates/trippy-tui/src/frontend/render/settings.rs
+++ b/crates/trippy-tui/src/frontend/render/settings.rs
@@ -591,7 +591,7 @@ fn format_as_mode(as_mode: AsMode) -> String {
 /// Format the `AddressMode`.
 fn format_address_mode(address_mode: AddressMode) -> String {
     match address_mode {
-        AddressMode::IP => "ip".to_string(),
+        AddressMode::Ip => "ip".to_string(),
         AddressMode::Host => "host".to_string(),
         AddressMode::Both => "both".to_string(),
     }
diff --git a/crates/trippy-tui/src/frontend/render/table.rs b/crates/trippy-tui/src/frontend/render/table.rs
index bcd24d776..15d0978ea 100644
--- a/crates/trippy-tui/src/frontend/render/table.rs
+++ b/crates/trippy-tui/src/frontend/render/table.rs
@@ -307,7 +307,7 @@ fn format_address(
     config: &TuiConfig,
 ) -> String {
     let addr_fmt = match config.address_mode {
-        AddressMode::IP => addr.to_string(),
+        AddressMode::Ip => addr.to_string(),
         AddressMode::Host => {
             if config.lookup_as_info {
                 let entry = dns.lazy_reverse_lookup_with_asinfo(*addr);


Test patch: