Skip to content

Commit 490ef98

Browse files
committed
process: hide internal structure
1 parent cd4ec24 commit 490ef98

File tree

6 files changed

+15
-17
lines changed

6 files changed

+15
-17
lines changed

src/cli/common.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use crate::{
2121
errors::RustupError,
2222
install::UpdateStatus,
2323
notifications::Notification,
24-
process::{Process, terminal_source},
24+
process::{Attr, Process},
2525
toolchain::{LocalToolchainName, Toolchain, ToolchainName},
2626
utils::{self, notify::NotificationLevel},
2727
};
@@ -256,7 +256,7 @@ fn show_channel_updates(
256256
let padding = max_width - width;
257257
let padding: String = " ".repeat(padding);
258258
let _ = write!(t.lock(), " {padding}");
259-
let _ = t.attr(terminal_source::Attr::Bold);
259+
let _ = t.attr(Attr::Bold);
260260
if let Some(color) = color {
261261
let _ = t.fg(color);
262262
}
@@ -311,7 +311,7 @@ pub(super) fn list_items(
311311
let mut t = process.stdout();
312312
for (name, installed) in items {
313313
if installed && !installed_only && !quiet {
314-
t.attr(terminal_source::Attr::Bold)?;
314+
t.attr(Attr::Bold)?;
315315
writeln!(t.lock(), "{name} (installed)")?;
316316
t.reset()?;
317317
} else if installed || !installed_only {

src/cli/markdown.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::io::Write;
44
use pulldown_cmark::{Event, Tag, TagEnd};
55
use termcolor::Color;
66

7-
use crate::process::terminal_source::{Attr, ColorableTerminal};
7+
use crate::process::{Attr, ColorableTerminal};
88

99
// Handles the wrapping of text written to the console
1010
struct LineWrapper<'a> {

src/cli/rustup_mode.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@ use crate::{
3838
},
3939
errors::RustupError,
4040
install::{InstallMethod, UpdateStatus},
41-
process::{
42-
Process,
43-
terminal_source::{self, ColorableTerminal},
44-
},
41+
process::{Attr, ColorableTerminal, Process},
4542
toolchain::{
4643
CustomToolchainName, DistributableToolchain, LocalToolchainName,
4744
MaybeResolvableToolchainName, ResolvableLocalToolchainName, ResolvableToolchainName,
@@ -1074,7 +1071,7 @@ async fn show(cfg: &Cfg<'_>, verbose: bool) -> Result<utils::ExitCode> {
10741071
// Print host triple
10751072
{
10761073
let mut t = cfg.process.stdout();
1077-
t.attr(terminal_source::Attr::Bold)?;
1074+
t.attr(Attr::Bold)?;
10781075
write!(t.lock(), "Default host: ")?;
10791076
t.reset()?;
10801077
writeln!(t.lock(), "{}", cfg.get_default_host_triple()?)?;
@@ -1083,7 +1080,7 @@ async fn show(cfg: &Cfg<'_>, verbose: bool) -> Result<utils::ExitCode> {
10831080
// Print rustup home directory
10841081
{
10851082
let mut t = cfg.process.stdout();
1086-
t.attr(terminal_source::Attr::Bold)?;
1083+
t.attr(Attr::Bold)?;
10871084
write!(t.lock(), "rustup home: ")?;
10881085
t.reset()?;
10891086
writeln!(t.lock(), "{}", cfg.rustup_dir.display())?;
@@ -1195,7 +1192,7 @@ async fn show(cfg: &Cfg<'_>, verbose: bool) -> Result<utils::ExitCode> {
11951192
where
11961193
E: From<io::Error>,
11971194
{
1198-
t.attr(terminal_source::Attr::Bold)?;
1195+
t.attr(Attr::Bold)?;
11991196
{
12001197
let mut term_lock = t.lock();
12011198
writeln!(term_lock, "{s}")?;

src/cli/self_update.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ use serde::{Deserialize, Serialize};
5050
use termcolor::Color;
5151
use tracing::{error, info, trace, warn};
5252

53-
use crate::download::download_file;
5453
use crate::{
5554
DUP_TOOLS, TOOLS,
5655
cli::{
@@ -60,9 +59,10 @@ use crate::{
6059
},
6160
config::Cfg,
6261
dist::{self, PartialToolchainDesc, Profile, TargetTriple, ToolchainDesc},
62+
download::download_file,
6363
errors::RustupError,
6464
install::UpdateStatus,
65-
process::{Process, terminal_source},
65+
process::{Attr, Process},
6666
toolchain::{
6767
DistributableToolchain, MaybeOfficialToolchainName, ResolvableToolchainName, Toolchain,
6868
ToolchainName,
@@ -1356,7 +1356,7 @@ pub(crate) async fn check_rustup_update(process: &Process) -> anyhow::Result<boo
13561356
// Get available rustup version
13571357
let available_version = get_available_rustup_version(process).await?;
13581358

1359-
let _ = t.attr(terminal_source::Attr::Bold);
1359+
let _ = t.attr(Attr::Bold);
13601360
write!(t.lock(), "rustup - ")?;
13611361

13621362
Ok(if current_version != available_version {

src/cli/self_update/windows.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use super::{InstallOpts, install_bins, report_error};
2323
use crate::cli::{download_tracker::DownloadTracker, markdown::md};
2424
use crate::dist::TargetTriple;
2525
use crate::download::download_file;
26-
use crate::process::{Process, terminalsource::ColorableTerminal};
26+
use crate::process::{ColorableTerminal, Process};
2727
use crate::utils;
2828

2929
pub(crate) fn ensure_prompt(process: &Process) -> Result<()> {

src/process.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ use tracing_subscriber::{EnvFilter, Registry, reload::Handle};
2626
#[cfg(all(feature = "test", feature = "otel"))]
2727
use crate::cli::log;
2828

29-
pub mod file_source;
30-
pub mod terminal_source;
29+
mod file_source;
30+
mod terminal_source;
31+
pub use terminal_source::{Attr, ColorableTerminal};
3132

3233
/// Allows concrete types for the process abstraction.
3334
#[derive(Clone, Debug)]

0 commit comments

Comments
 (0)