Files
dev_tools/src/main.rs
T
mathias 9f4a0dc446 Preserve trailing newlines and restore connections.env via git checkout on down
Fix set_local_db/set_dot_env unconditionally stripping (then forcing)
the file's trailing newline: they now detect whether the source file
originally ended in a newline and reproduce that on write, verified
against both the newline and no-newline cases.

Replace the reverse-toggle computation for connections.env on `down`
with a straight `git checkout`, so the file always ends up
byte-for-byte identical to HEAD instead of relying on toggle logic to
get it exactly right. Both git call sites now go through a shared
helper that checks the process exit status and errors out instead of
silently reporting success on a failed checkout/update-index, with
test coverage against real temporary git repos.
2026-09-17 15:44:14 +02:00

42 lines
1.0 KiB
Rust

use anyhow::Result;
use container::docker::start_docker_compose;
use env::config::{load_config, DevToolsConf};
use crate::{
arguments::Arguments,
config::parse::{set_dot_env, set_local_db},
git::command::{restore_connections_env, toggle_index},
};
use clap::Parser;
mod arguments;
mod config;
mod container;
mod env;
mod git;
fn main() -> Result<()> {
let args: Arguments = Arguments::parse();
args.validate()?;
let config: DevToolsConf = load_config(&args)?;
let start: bool = args.action == "up";
start_docker_compose(&config.container_service, &config.container_dir, start)?;
if start {
print!("{}", set_local_db(start, &config)?);
}
toggle_index(start, &config)?;
if !start {
restore_connections_env(&config)?;
println!("[!] conf/global/connections.env restored to committed state.");
}
print!("{}", set_dot_env(start, &config)?);
println!(
"[!] Don't forget your interpreter! Project directory: {}",
config.project_dir_as_string()
);
Ok(())
}