@@ -23,20 +23,29 @@ namespace AppInstaller::CLI::Execution
2323 const Sequence& ConfigurationUnitEmphasis = TextFormat::Foreground::BrightCyan;
2424 const Sequence& AuthenticationEmphasis = TextFormat::Foreground::BrightYellow;
2525
26- Reporter::Reporter () :
27- Reporter (std::cout, std::cin)
26+ namespace
2827 {
29- HANDLE outHandle = GetStdHandle (STD_OUTPUT_HANDLE);
30- if (outHandle == INVALID_HANDLE_VALUE)
31- {
32- LOG_LAST_ERROR ();
33- }
34- else if (outHandle != NULL )
28+ DWORD GetStdHandleType (DWORD stdHandle)
3529 {
30+ DWORD result = FILE_TYPE_UNKNOWN;
31+
32+ HANDLE handle = GetStdHandle (stdHandle);
33+ if (handle != INVALID_HANDLE_VALUE && handle != NULL )
34+ {
35+ result = GetFileType (handle);
36+ }
3637
38+ return result;
3739 }
3840 }
3941
42+ Reporter::Reporter () :
43+ Reporter (std::cout, std::cin)
44+ {
45+ m_outStreamFileType = GetStdHandleType (STD_OUTPUT_HANDLE);
46+ m_inStreamFileType = GetStdHandleType (STD_INPUT_HANDLE);
47+ }
48+
4049 Reporter::Reporter (std::ostream& outStream, std::istream& inStream) :
4150 Reporter (std::make_shared<BaseStream>(outStream, true , ConsoleModeRestore::Instance().IsVTEnabled()), inStream)
4251 {
@@ -62,6 +71,9 @@ namespace AppInstaller::CLI::Execution
6271 Reporter::Reporter (const Reporter& other, clone_t ) :
6372 Reporter (other.m_out, other.m_in)
6473 {
74+ m_outStreamFileType = other.m_outStreamFileType ;
75+ m_inStreamFileType = other.m_inStreamFileType ;
76+
6577 SetChannel (other.m_channel );
6678
6779 if (other.m_style .has_value ())
@@ -154,7 +166,7 @@ namespace AppInstaller::CLI::Execution
154166
155167 bool Reporter::InputStreamIsInteractive () const
156168 {
157-
169+ return m_inStreamFileType == FILE_TYPE_CHAR;
158170 }
159171
160172 bool Reporter::PromptForBoolResponse (Resource::LocString message, Level level, bool resultIfDisabled)
0 commit comments