feat: swap println for eprintln or debug_eprintln
Unified expected output to always eprintln so outputs can be piped to other processes. Added debug_eprintln and switched all occurances of debug_println.
This commit is contained in:
@@ -8,7 +8,7 @@ use std::{
|
||||
};
|
||||
|
||||
use super::docker_compose;
|
||||
use crate::{command_builder::CommandBuilder, debug_println};
|
||||
use crate::{command_builder::CommandBuilder, debug_eprintln};
|
||||
|
||||
fn get_containers() -> Result<[String; 2]> {
|
||||
// get db container
|
||||
@@ -40,13 +40,13 @@ pub fn import(file: &Path) -> Result<()> {
|
||||
let [db_container, app_containers] = get_containers()?;
|
||||
let dump_file = file.to_string_lossy();
|
||||
|
||||
println!("stopping all containers");
|
||||
eprintln!("stopping all containers");
|
||||
docker_compose::stop()?;
|
||||
|
||||
println!("starting db container");
|
||||
eprintln!("starting db container");
|
||||
docker_compose::start(Some("postgresdb"))?;
|
||||
|
||||
println!("restoring database");
|
||||
eprintln!("restoring database");
|
||||
let commands = [
|
||||
format!("cp {dump_file} {db_container}:/tmp/dbdump"),
|
||||
format!("exec {db_container} dropdb -U db db"),
|
||||
@@ -55,7 +55,7 @@ pub fn import(file: &Path) -> Result<()> {
|
||||
];
|
||||
|
||||
for command in commands {
|
||||
debug_println!("waiting until pg_isready");
|
||||
debug_eprintln!("waiting until pg_isready");
|
||||
while !CommandBuilder::docker()
|
||||
.args(&format!(
|
||||
"exec {db_container} pg_isready -h postgresdb -p 5432 -U db",
|
||||
@@ -71,7 +71,7 @@ pub fn import(file: &Path) -> Result<()> {
|
||||
CommandBuilder::docker().args(&command).exec()?;
|
||||
}
|
||||
|
||||
println!("restarting containers");
|
||||
eprintln!("restarting containers");
|
||||
docker_compose::stop()?;
|
||||
docker_compose::up()?;
|
||||
|
||||
@@ -81,7 +81,7 @@ pub fn import(file: &Path) -> Result<()> {
|
||||
pub fn dump(file: &PathBuf) -> Result<()> {
|
||||
let [db_container, _] = get_containers()?;
|
||||
|
||||
println!("dumping to local file {}", file.to_string_lossy());
|
||||
eprintln!("dumping to local file {}", file.to_string_lossy());
|
||||
|
||||
let file = File::create(file)?;
|
||||
let stdout = Stdio::from(file);
|
||||
|
||||
Reference in New Issue
Block a user