| 1 | use clearscreenrust-analyzer cargo clearscreen 4.0.2 crate/::ClearScreenrust-analyzer cargo clearscreen 4.0.2 ClearScreen#; |
| 2 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::{envrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/, threadrust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/::sleeprust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/functions/sleep()., timerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/::Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#}; |
| 3 | use thiserrorrust-analyzer cargo thiserror 2.0.11 crate/::Errorrust-analyzer cargo thiserror-impl 2.0.11 Error:; |
| 4 | |
| 5 | fn mainrust-analyzer cargo clearscreen 4.0.2 main().() -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo clearscreen 4.0.2 Error#> { |
| 6 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(variant) = envrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/::argsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/args().().nthrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#nth().(1) { |
| 7 | let cs = match variant.as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().() { |
| 8 | "auto" => ClearScreenrust-analyzer cargo clearscreen 4.0.2 ClearScreen#::defaultrust-analyzer cargo clearscreen 4.0.2 impl#[ClearScreen][Default]default().(), |
| 9 | "Terminfo" => ClearScreenrust-analyzer cargo clearscreen 4.0.2 ClearScreen#::Terminforust-analyzer cargo clearscreen 4.0.2 ClearScreen#Terminfo#, |
| 10 | "TerminfoScreen" => ClearScreenrust-analyzer cargo clearscreen 4.0.2 ClearScreen#::TerminfoScreenrust-analyzer cargo clearscreen 4.0.2 ClearScreen#TerminfoScreen#, |
| 11 | "TerminfoScrollback" => ClearScreenrust-analyzer cargo clearscreen 4.0.2 ClearScreen#::TerminfoScrollbackrust-analyzer cargo clearscreen 4.0.2 ClearScreen#TerminfoScrollback#, |
| 12 | "TerminfoReset" => ClearScreenrust-analyzer cargo clearscreen 4.0.2 ClearScreen#::TerminfoResetrust-analyzer cargo clearscreen 4.0.2 ClearScreen#TerminfoReset#, |
| 13 | "XtermClear" => ClearScreenrust-analyzer cargo clearscreen 4.0.2 ClearScreen#::XtermClearrust-analyzer cargo clearscreen 4.0.2 ClearScreen#XtermClear#, |
| 14 | "XtermReset" => ClearScreenrust-analyzer cargo clearscreen 4.0.2 ClearScreen#::XtermResetrust-analyzer cargo clearscreen 4.0.2 ClearScreen#XtermReset#, |
| 15 | "TputClear" => ClearScreenrust-analyzer cargo clearscreen 4.0.2 ClearScreen#::TputClearrust-analyzer cargo clearscreen 4.0.2 ClearScreen#TputClear#, |
| 16 | "TputReset" => ClearScreenrust-analyzer cargo clearscreen 4.0.2 ClearScreen#::TputResetrust-analyzer cargo clearscreen 4.0.2 ClearScreen#TputReset#, |
| 17 | "Cls" => ClearScreenrust-analyzer cargo clearscreen 4.0.2 ClearScreen#::Clsrust-analyzer cargo clearscreen 4.0.2 ClearScreen#Cls#, |
| 18 | "WindowsVt" => ClearScreenrust-analyzer cargo clearscreen 4.0.2 ClearScreen#::WindowsVtrust-analyzer cargo clearscreen 4.0.2 ClearScreen#WindowsVt#, |
| 19 | "WindowsVtClear" => ClearScreenrust-analyzer cargo clearscreen 4.0.2 ClearScreen#::WindowsVtClearrust-analyzer cargo clearscreen 4.0.2 ClearScreen#WindowsVtClear#, |
| 20 | #[cfg(feature = "windows-console")] |
| 21 | "WindowsConsoleClear" => ClearScreenrust-analyzer cargo clearscreen 4.0.2 ClearScreen#::WindowsConsoleClear, |
| 22 | #[cfg(feature = "windows-console")] |
| 23 | "WindowsConsoleBlank" => ClearScreenrust-analyzer cargo clearscreen 4.0.2 ClearScreen#::WindowsConsoleBlank, |
| 24 | "WindowsCooked" => ClearScreenrust-analyzer cargo clearscreen 4.0.2 ClearScreen#::WindowsCookedrust-analyzer cargo clearscreen 4.0.2 ClearScreen#WindowsCooked#, |
| 25 | "VtRis" => ClearScreenrust-analyzer cargo clearscreen 4.0.2 ClearScreen#::VtRisrust-analyzer cargo clearscreen 4.0.2 ClearScreen#VtRis#, |
| 26 | "VtLeaveAlt" => ClearScreenrust-analyzer cargo clearscreen 4.0.2 ClearScreen#::VtLeaveAltrust-analyzer cargo clearscreen 4.0.2 ClearScreen#VtLeaveAlt#, |
| 27 | "VtCooked" => ClearScreenrust-analyzer cargo clearscreen 4.0.2 ClearScreen#::VtCookedrust-analyzer cargo clearscreen 4.0.2 ClearScreen#VtCooked#, |
| 28 | "VtWellDone" => ClearScreenrust-analyzer cargo clearscreen 4.0.2 ClearScreen#::VtWellDonerust-analyzer cargo clearscreen 4.0.2 ClearScreen#VtWellDone#, |
| 29 | _ => return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo clearscreen 4.0.2 Error#::UnknownVariantrust-analyzer cargo clearscreen 4.0.2 Error#UnknownVariant#(variant)), |
| 30 | }; |
| 31 | |
| 32 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("variant = {:?}, sleeping 1 second", cs); |
| 33 | sleeprust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/functions/sleep().(Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#::from_secsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]from_secs().(1)); |
| 34 | cs.clearrust-analyzer cargo clearscreen 4.0.2 impl#[ClearScreen]clear().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 35 | |
| 36 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 37 | } else { |
| 38 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("Usage: cargo run --example clscli -- <variant>\nWhere <variant> is one of the ClearScreen enum variants, same casing, or 'auto'.\nI recommend piping into `hexdump -C` to see what’s happening."); |
| 39 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Errorrust-analyzer cargo thiserror-impl 2.0.11 Error:)] |
| 44 | enum Errorrust-analyzer cargo clearscreen 4.0.2 Error# { |
| 45 | #[errorrust-analyzer cargo thiserror-impl 2.0.11 error:("unknown variant: {0}")] |
| 46 | UnknownVariantrust-analyzer cargo clearscreen 4.0.2 Error#UnknownVariant#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#), |
| 47 | |
| 48 | #[errorrust-analyzer cargo thiserror-impl 2.0.11 error:(transparent)] |
| 49 | ClearScreenrust-analyzer cargo clearscreen 4.0.2 Error#ClearScreen#(#[from] clearscreenrust-analyzer cargo clearscreen 4.0.2 crate/::Errorrust-analyzer cargo clearscreen 4.0.2 Error#), |
| 50 | } |