From d2e445a207a1e5aa6d745b3f68eb7b6ec6ed328d Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Mon, 14 Aug 2023 16:42:16 -0700 Subject: [PATCH] finally, rename IsATTY variants to Yes and No --- crates/wasi/src/preview2/ctx.rs | 18 +++++++++--------- crates/wasi/src/preview2/preview1/mod.rs | 16 ++++++++-------- crates/wasi/src/preview2/stdio.rs | 10 +++++----- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/crates/wasi/src/preview2/ctx.rs b/crates/wasi/src/preview2/ctx.rs index 88b21abcb745..252307c80faf 100644 --- a/crates/wasi/src/preview2/ctx.rs +++ b/crates/wasi/src/preview2/ctx.rs @@ -57,9 +57,9 @@ impl WasiCtxBuilder { let insecure_random_seed = cap_rand::thread_rng(cap_rand::ambient_authority()).gen::(); Self { - stdin: (Box::new(pipe::ClosedInputStream), IsATTY::None), - stdout: (Box::new(pipe::SinkOutputStream), IsATTY::None), - stderr: (Box::new(pipe::SinkOutputStream), IsATTY::None), + stdin: (Box::new(pipe::ClosedInputStream), IsATTY::No), + stdout: (Box::new(pipe::SinkOutputStream), IsATTY::No), + stderr: (Box::new(pipe::SinkOutputStream), IsATTY::No), env: Vec::new(), args: Vec::new(), preopens: Vec::new(), @@ -91,9 +91,9 @@ impl WasiCtxBuilder { use is_terminal::IsTerminal; let inherited = stdio::stdin(); let isatty = if inherited.is_terminal() { - IsATTY::TTY + IsATTY::Yes } else { - IsATTY::None + IsATTY::No }; self.stdin(inherited, isatty) } @@ -102,9 +102,9 @@ impl WasiCtxBuilder { use is_terminal::IsTerminal; let inherited = stdio::stdout(); let isatty = if inherited.is_terminal() { - IsATTY::TTY + IsATTY::Yes } else { - IsATTY::None + IsATTY::No }; self.stdout(inherited, isatty) } @@ -113,9 +113,9 @@ impl WasiCtxBuilder { use is_terminal::IsTerminal; let inherited = stdio::stderr(); let isatty = if inherited.is_terminal() { - IsATTY::TTY + IsATTY::Yes } else { - IsATTY::None + IsATTY::No }; self.stderr(inherited, isatty) } diff --git a/crates/wasi/src/preview2/preview1/mod.rs b/crates/wasi/src/preview2/preview1/mod.rs index 0edff85f6021..965e192dbae2 100644 --- a/crates/wasi/src/preview2/preview1/mod.rs +++ b/crates/wasi/src/preview2/preview1/mod.rs @@ -108,9 +108,9 @@ impl Descriptors { host.drop_terminal_input(term_in) .context("failed to call `drop-terminal-input`") .map_err(types::Error::trap)?; - IsATTY::TTY + IsATTY::Yes } else { - IsATTY::None + IsATTY::No }, })?; descriptors.push(Descriptor::Stdout { @@ -126,9 +126,9 @@ impl Descriptors { host.drop_terminal_output(term_out) .context("failed to call `drop-terminal-output`") .map_err(types::Error::trap)?; - IsATTY::TTY + IsATTY::Yes } else { - IsATTY::None + IsATTY::No }, })?; descriptors.push(Descriptor::Stderr { @@ -144,9 +144,9 @@ impl Descriptors { host.drop_terminal_output(term_out) .context("failed to call `drop-terminal-output`") .map_err(types::Error::trap)?; - IsATTY::TTY + IsATTY::Yes } else { - IsATTY::None + IsATTY::No }, })?; @@ -529,8 +529,8 @@ impl TryFrom for types::Filetype { impl From for types::Filetype { fn from(isatty: IsATTY) -> Self { match isatty { - IsATTY::TTY => types::Filetype::CharacterDevice, - IsATTY::None => types::Filetype::Unknown, + IsATTY::Yes => types::Filetype::CharacterDevice, + IsATTY::No => types::Filetype::Unknown, } } } diff --git a/crates/wasi/src/preview2/stdio.rs b/crates/wasi/src/preview2/stdio.rs index efaeecd65e45..947a4885f558 100644 --- a/crates/wasi/src/preview2/stdio.rs +++ b/crates/wasi/src/preview2/stdio.rs @@ -61,8 +61,8 @@ impl HostOutputStream for Stderr { #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum IsATTY { - TTY, - None, + Yes, + No, } pub(crate) struct StdioInput { @@ -110,7 +110,7 @@ impl terminal_output::Host for T { } impl terminal_stdin::Host for T { fn get_terminal_stdin(&mut self) -> anyhow::Result> { - if let IsATTY::TTY = self.ctx().stdin.isatty { + if let IsATTY::Yes = self.ctx().stdin.isatty { Ok(Some(self.table_mut().push(Box::new(HostTerminalInput))?)) } else { Ok(None) @@ -119,7 +119,7 @@ impl terminal_stdin::Host for T { } impl terminal_stdout::Host for T { fn get_terminal_stdout(&mut self) -> anyhow::Result> { - if let IsATTY::TTY = self.ctx().stdout.isatty { + if let IsATTY::Yes = self.ctx().stdout.isatty { Ok(Some(self.table_mut().push(Box::new(HostTerminalOutput))?)) } else { Ok(None) @@ -128,7 +128,7 @@ impl terminal_stdout::Host for T { } impl terminal_stderr::Host for T { fn get_terminal_stderr(&mut self) -> anyhow::Result> { - if let IsATTY::TTY = self.ctx().stderr.isatty { + if let IsATTY::Yes = self.ctx().stderr.isatty { Ok(Some(self.table_mut().push(Box::new(HostTerminalOutput))?)) } else { Ok(None)