Skip to content

Commit f215d88

Browse files
committed
fix windows ANSI terminal coloring problem
1 parent 427ee24 commit f215d88

4 files changed

Lines changed: 36 additions & 46 deletions

File tree

.github/workflows/build.yml

Lines changed: 24 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -40,59 +40,40 @@ jobs:
4040
- name: Build Release Binary
4141
run: cargo build --release
4242

43-
- name: Rename Linux/Mac Binary
44-
if: matrix.os != 'windows-latest'
45-
run: mv target/release/zond target/release/zond-${{ runner.os }}
43+
- name: Package Windows Binary
44+
if: matrix.os == 'windows-latest'
45+
run: |
46+
powershell Compress-Archive -Path target/release/zond.exe -DestinationPath target/release/zond-windows.zip
4647
47-
- name: Upload Binary (Linux & macOS)
48-
if: matrix.os != 'windows-latest'
49-
uses: actions/upload-artifact@v4
50-
with:
51-
name: zond-${{ matrix.os }}-binary
52-
path: target/release/zond-${{ runner.os }}
48+
- name: Package MacOS Binary
49+
if: matrix.os == 'macos-latest'
50+
run: |
51+
cd target/release
52+
zip zond-macos.zip zond
53+
54+
- name: Package Linux Binary
55+
if: matrix.os == 'ubuntu-latest'
56+
run: |
57+
cd target/release
58+
tar -czf zond-linux.tar.gz zond
5359
5460
- name: Build Windows Installer (Inno Setup)
5561
if: matrix.os == 'windows-latest'
5662
run: iscc packaging/windows/zond_installer.iss
5763

58-
- name: Upload Zond Setup (Windows)
59-
if: matrix.os == 'windows-latest'
60-
uses: actions/upload-artifact@v4
61-
with:
62-
name: zond-windows-installer
63-
path: target/release/Zond_Setup.exe
64-
65-
- name: Install cargo-deb (Linux only)
66-
if: matrix.os == 'ubuntu-latest'
67-
run: cargo install cargo-deb
68-
6964
- name: Build Debian Package
7065
if: matrix.os == 'ubuntu-latest'
71-
run: cargo deb -p zond-cli
72-
73-
- name: Upload Debian Package
74-
if: matrix.os == 'ubuntu-latest'
75-
uses: actions/upload-artifact@v4
76-
with:
77-
name: zond-debian-package
78-
path: target/debian/*.deb
79-
80-
- name: Release Linux/macOS Binary
81-
if: startsWith(github.ref, 'refs/tags/') && matrix.os != 'windows-latest'
82-
uses: softprops/action-gh-release@v2
83-
with:
84-
files: target/release/zond-${{ runner.os }}
66+
run: |
67+
cargo install cargo-deb
68+
cargo deb -p zond-cli
8569
86-
- name: Release Windows Files
87-
if: startsWith(github.ref, 'refs/tags/') && matrix.os == 'windows-latest'
70+
- name: Release Files
71+
if: startsWith(github.ref, 'refs/tags/')
8872
uses: softprops/action-gh-release@v2
8973
with:
9074
files: |
91-
target/release/zond.exe
75+
target/release/zond-windows.zip
76+
target/release/zond-macos.zip
77+
target/release/zond-linux.tar.gz
9278
target/release/Zond_Setup.exe
93-
94-
- name: Release Debian Package
95-
if: startsWith(github.ref, 'refs/tags/') && matrix.os == 'ubuntu-latest'
96-
uses: softprops/action-gh-release@v2
97-
with:
98-
files: target/debian/*.deb
79+
target/debian/*.deb

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cli/src/terminal/spinner.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ const STATUS_MS: u128 = 2000;
4949
/// 2. **Formatter**: Our custom `ZondFormatter` that makes logs look nice.
5050
/// 3. **Indicatif**: Ensures logs print *above* the spinner line, not over it.
5151
pub fn init_logging(verbosity: u8) {
52+
#[cfg(target_os = "windows")]
53+
let _ = colored::control::set_virtual_terminal(true);
54+
5255
let indicatif_layer = IndicatifLayer::new().with_progress_style(
5356
ProgressStyle::with_template("{spinner:.blue} {msg}")
5457
.unwrap()

common/src/interface.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,11 +513,17 @@ mod windows_impl {
513513
}
514514

515515
pub fn is_physical(interface: &NetworkInterface) -> bool {
516-
with_cache(|info| info.physical_devices.contains(&interface.name))
516+
with_cache(|info| {
517+
let name = interface.name.strip_prefix(r"\Device\NPF_").unwrap_or(&interface.name);
518+
info.physical_devices.contains(name)
519+
})
517520
}
518521

519522
pub fn is_wireless(interface: &NetworkInterface) -> bool {
520-
with_cache(|info| info.wireless_devices.contains(&interface.name))
523+
with_cache(|info| {
524+
let name = interface.name.strip_prefix(r"\Device\NPF_").unwrap_or(&interface.name);
525+
info.wireless_devices.contains(name)
526+
})
521527
}
522528
}
523529

0 commit comments

Comments
 (0)