Skip to content

Commit

Permalink
finally, rename IsATTY variants to Yes and No
Browse files Browse the repository at this point in the history
  • Loading branch information
Pat Hickey committed Aug 14, 2023
1 parent f24a1a4 commit d2e445a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
18 changes: 9 additions & 9 deletions crates/wasi/src/preview2/ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ impl WasiCtxBuilder {
let insecure_random_seed =
cap_rand::thread_rng(cap_rand::ambient_authority()).gen::<u128>();
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(),
Expand Down Expand Up @@ -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)
}
Expand All @@ -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)
}
Expand All @@ -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)
}
Expand Down
16 changes: 8 additions & 8 deletions crates/wasi/src/preview2/preview1/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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
},
})?;

Expand Down Expand Up @@ -529,8 +529,8 @@ impl TryFrom<filesystem::DescriptorType> for types::Filetype {
impl From<IsATTY> 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,
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions crates/wasi/src/preview2/stdio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -110,7 +110,7 @@ impl<T: WasiView> terminal_output::Host for T {
}
impl<T: WasiView> terminal_stdin::Host for T {
fn get_terminal_stdin(&mut self) -> anyhow::Result<Option<terminal_input::TerminalInput>> {
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)
Expand All @@ -119,7 +119,7 @@ impl<T: WasiView> terminal_stdin::Host for T {
}
impl<T: WasiView> terminal_stdout::Host for T {
fn get_terminal_stdout(&mut self) -> anyhow::Result<Option<terminal_output::TerminalOutput>> {
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)
Expand All @@ -128,7 +128,7 @@ impl<T: WasiView> terminal_stdout::Host for T {
}
impl<T: WasiView> terminal_stderr::Host for T {
fn get_terminal_stderr(&mut self) -> anyhow::Result<Option<terminal_output::TerminalOutput>> {
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)
Expand Down

0 comments on commit d2e445a

Please sign in to comment.