Skip to content

Commit 1be3a25

Browse files
author
Steve Lee (POWERSHELL HE/HIM) (from Dev Box)
committed
remove use of ATTY
1 parent c8a6968 commit 1be3a25

File tree

17 files changed

+160
-261
lines changed

17 files changed

+160
-261
lines changed

.pipelines/DSC-Official.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ variables:
2121
# LinuxContainerImage: 'mcr.microsoft.com/onebranch/cbl-mariner/build:2.0'
2222
LinuxContainerImage: 'onebranch.azurecr.io/linux/ubuntu-2204:latest'
2323
WindowsContainerImage: 'onebranch.azurecr.io/windows/ltsc2022/vse2022:latest'
24+
Codeql.TSAEnabled: true
2425

2526
resources:
2627
repositories:

dsc/Cargo.lock

Lines changed: 1 addition & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dsc/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ opt-level = 2
1111
lto = true
1212

1313
[dependencies]
14-
atty = { version = "0.2" }
1514
clap = { version = "4.5.17", features = ["derive"] }
1615
clap_complete = { version = "4.5.28" }
1716
crossterm = { version = "0.28.1" }

dsc/src/main.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
// Licensed under the MIT License.
33

44
use args::{Args, SubCommand};
5-
use atty::Stream;
65
use clap::{CommandFactory, Parser};
76
use clap_complete::generate;
8-
use std::io::{self, Read};
7+
use std::io::{self, IsTerminal, Read};
98
use std::process::exit;
109
use sysinfo::{Process, RefreshKind, System, get_current_pid, ProcessRefreshKind};
1110
use tracing::{error, info, warn, debug};
@@ -39,7 +38,7 @@ fn main() {
3938

4039
debug!("Running dsc {}", env!("CARGO_PKG_VERSION"));
4140

42-
let input = if atty::is(Stream::Stdin) {
41+
let input = if io::stdin().is_terminal() {
4342
None
4443
} else {
4544
info!("Reading input from STDIN");

dsc/src/subcommand.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
use crate::args::{ConfigSubCommand, DscType, OutputFormat, ResourceSubCommand};
55
use crate::resolve::{get_contents, Include};
66
use crate::resource_command::{get_resource, self};
7-
use crate::Stream;
87
use crate::tablewriter::Table;
98
use crate::util::{DSC_CONFIG_ROOT, EXIT_DSC_ERROR, EXIT_INVALID_INPUT, EXIT_JSON_ERROR, get_schema, write_output, get_input, set_dscconfigroot, validate_json};
109
use dsc_lib::configure::{Configurator, config_doc::{Configuration, ExecutionKind}, config_result::ResourceGetResult};
@@ -17,6 +16,7 @@ use dsc_lib::{
1716
dscresources::resource_manifest::{import_manifest, ResourceManifest},
1817
};
1918
use std::collections::HashMap;
19+
use std::io::{self, IsTerminal};
2020
use std::process::exit;
2121
use tracing::{debug, error, trace};
2222

@@ -498,7 +498,7 @@ pub fn resource(subcommand: &ResourceSubCommand, stdin: &Option<String>) {
498498
fn list_resources(dsc: &mut DscManager, resource_name: &Option<String>, adapter_name: &Option<String>, description: &Option<String>, tags: &Option<Vec<String>>, format: &Option<OutputFormat>) {
499499
let mut write_table = false;
500500
let mut table = Table::new(&["Type", "Kind", "Version", "Caps", "RequireAdapter", "Description"]);
501-
if format.is_none() && atty::is(Stream::Stdout) {
501+
if format.is_none() && io::stdin().is_terminal() {
502502
// write as table if format is not specified and interactive
503503
write_table = true;
504504
}
@@ -580,7 +580,7 @@ fn list_resources(dsc: &mut DscManager, resource_name: &Option<String>, adapter_
580580
};
581581
write_output(&json, format);
582582
// insert newline separating instances if writing to console
583-
if atty::is(Stream::Stdout) { println!(); }
583+
if io::stdin().is_terminal() { println!(); }
584584
}
585585
}
586586

dsc/src/util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Licensed under the MIT License.
33

44
use crate::args::{DscType, OutputFormat, TraceFormat};
5-
use atty::Stream;
65
use crate::resolve::Include;
76
use dsc_lib::{
87
configure::{
@@ -31,6 +30,7 @@ use schemars::{schema_for, schema::RootSchema};
3130
use serde_json::Value;
3231
use std::collections::HashMap;
3332
use std::env;
33+
use std::io::IsTerminal;
3434
use std::path::Path;
3535
use std::process::exit;
3636
use syntect::{
@@ -194,7 +194,7 @@ pub fn write_output(json: &str, format: &Option<OutputFormat>) {
194194
let mut is_json = true;
195195
let mut output_format = format.clone();
196196
let mut syntax_color = false;
197-
if atty::is(Stream::Stdout) {
197+
if std::io::stdin().is_terminal() {
198198
syntax_color = true;
199199
if output_format.is_none() {
200200
output_format = Some(OutputFormat::Yaml);

runcommandonset/Cargo.lock

Lines changed: 0 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

runcommandonset/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ edition = "2021"
66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

88
[dependencies]
9-
atty = { version = "0.2.0" }
109
clap = { version = "4.4.0", features = ["derive"] }
1110
serde = { version = "1.0.0", features = ["derive"] }
1211
serde_json = { version = "1.0.0", features = ["preserve_order"] }

runcommandonset/src/main.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
use atty::Stream;
54
use clap::Parser;
6-
use std::{io::{self, Read}, process::exit};
5+
use std::{io::{self, Read, IsTerminal}, process::exit};
76
use tracing::{error, warn, debug};
87

98
use args::{Arguments, SubCommand, TraceLevel};
@@ -41,7 +40,7 @@ fn main() {
4140
enable_tracing(&trace_level, &args.trace_format);
4241
warn!("This resource is not idempotent");
4342

44-
let stdin = if atty::is(Stream::Stdin) {
43+
let stdin = if std::io::stdin().is_terminal() {
4544
None
4645
} else {
4746
debug!("Reading input from STDIN");

tree-sitter-dscexpression/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ path = "bindings/rust/lib.rs"
2323
tree-sitter = "0.24.3"
2424

2525
[build-dependencies]
26-
cc = "1.1.20"
26+
cc = "1.1"

0 commit comments

Comments
 (0)