Remove the unstable CLI warning.
This commit is contained in:
parent
68e355690b
commit
69e21afd60
@ -38,14 +38,10 @@ impl FileOrStdout {
|
|||||||
|
|
||||||
/// Opens the file (or stdout) for writing data that is NOT safe
|
/// Opens the file (or stdout) for writing data that is NOT safe
|
||||||
/// for non-interactive use.
|
/// for non-interactive use.
|
||||||
///
|
|
||||||
/// If our heuristic detects non-interactive use, we will emit a
|
|
||||||
/// warning once.
|
|
||||||
pub fn create_unsafe(
|
pub fn create_unsafe(
|
||||||
&self,
|
&self,
|
||||||
sq: &Sq,
|
sq: &Sq,
|
||||||
) -> Result<Box<dyn Write + Sync + Send>> {
|
) -> Result<Box<dyn Write + Sync + Send>> {
|
||||||
CliWarningOnce::warn();
|
|
||||||
self.create(sq)
|
self.create(sq)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,27 +166,3 @@ impl<W: io::Write + Send + Sync> SecretLeakDetector<W> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct CliWarningOnce(());
|
|
||||||
impl CliWarningOnce {
|
|
||||||
/// Emit a warning message only once
|
|
||||||
pub fn warn() {
|
|
||||||
use std::sync::Once;
|
|
||||||
static WARNING: Once = Once::new();
|
|
||||||
WARNING.call_once(|| {
|
|
||||||
// stdout is connected to a terminal, assume interactive use.
|
|
||||||
use std::io::IsTerminal;
|
|
||||||
if ! std::io::stdout().is_terminal()
|
|
||||||
// For bash shells, we can use a very simple heuristic.
|
|
||||||
// We simply look at whether the COLUMNS variable is defined in
|
|
||||||
// our environment.
|
|
||||||
&& std::env::var_os("COLUMNS").is_none() {
|
|
||||||
eprintln!(
|
|
||||||
"\nWARNING: sq does not have a stable CLI interface, \
|
|
||||||
and the human-readable output should not be parsed.\n\
|
|
||||||
Use with caution in scripts.\n"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user