added git update index
This commit is contained in:
+1
-2
@@ -4,7 +4,7 @@ use std::{
|
||||
};
|
||||
|
||||
use anyhow::Context;
|
||||
const GLOBAL_CONNECTION_PATH: &str = "conf/global/connections.env";
|
||||
pub const GLOBAL_CONNECTION_PATH: &str = "conf/global/connections.env";
|
||||
const LOCAL_CONNECTION_PATH: &str = "conf/local/.env";
|
||||
|
||||
pub fn set_local_db(start: bool) -> Result<(), Box<dyn std::error::Error>> {
|
||||
@@ -85,7 +85,6 @@ fn toggle_after_line(
|
||||
}
|
||||
|
||||
fn toggle(line: &str, activate: bool) -> String {
|
||||
dbg!(line, activate);
|
||||
if activate {
|
||||
return line.replacen('#', "", 1);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
use std::process::Command;
|
||||
|
||||
use crate::config::parse::GLOBAL_CONNECTION_PATH;
|
||||
|
||||
pub fn toggle_index(start: bool) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let change: &str = match start {
|
||||
true => "--assume-unchanged",
|
||||
false => "--no-assume-unchanged",
|
||||
};
|
||||
Command::new("git")
|
||||
.args(["update-index", change, "conf/global/connections.env"])
|
||||
.status()?;
|
||||
|
||||
if !start {
|
||||
Command::new("git")
|
||||
.args(["checkout", GLOBAL_CONNECTION_PATH])
|
||||
.status()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
pub mod command;
|
||||
+4
-1
@@ -4,6 +4,7 @@ use env::config::{load_config, DevToolsConf};
|
||||
use crate::{
|
||||
arguments::Arguments,
|
||||
config::parse::{set_dot_env, set_local_db},
|
||||
git::command::toggle_index,
|
||||
};
|
||||
use clap::Parser;
|
||||
|
||||
@@ -11,6 +12,7 @@ mod arguments;
|
||||
mod config;
|
||||
mod container;
|
||||
mod env;
|
||||
mod git;
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let args: Arguments = Arguments::parse();
|
||||
@@ -21,9 +23,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
start_docker_compose(&config.container_service, &config.container_dir, start)?;
|
||||
set_local_db(start)?;
|
||||
set_dot_env(start)?;
|
||||
toggle_index(start)?;
|
||||
|
||||
println!(
|
||||
"Current directory: {}",
|
||||
"Don't forget your interpreter! Current directory: {}",
|
||||
config.current_directory.as_path().to_str().unwrap()
|
||||
);
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user