crabtrap

Crates.iocrabtrap
lib.rscrabtrap
version0.1.0
sourcesrc
created_at2024-10-15 21:44:21.027538
updated_at2024-10-15 21:44:21.027538
descriptionDetect whether your app was launched from the terminal or from explorer/PowerToys in Windows
homepagehttps://github.com/FrancescoLuzzi/crabtrap
repositoryhttps://github.com/FrancescoLuzzi/crabtrap
max_upload_size
id1410734
size17,684
Francesco Luzzi (FrancescoLuzzi)

documentation

README

crabtrap

Rust porting of the golang library mousetrap

This is a tiny crate with a minimal footprint, that solves a simple problem:

Was the binary launched from the terminal or by double clicking on it?

This crate gives an answer in the Windows world, keeping the question open in all other operating systems (suggestions are welcome).

Example

use crabtrap::started_by_explorer;

fn main(){
    if started_by_explorer(){
        println!("I'm from a GUI");
    } else{
        println!("I'm from the terminal");
    }
}
Commit count: 13

cargo fmt