Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions cli/src/commands/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub fn execute(all: bool) -> ExitCode {

if all {
println!("Cleaning global package caches...");
if let Some(home) = home_dir() {
if let Some(home) = crate::dirs::home_dir() {
let cache_dir = home.join(".techscript").join("cache");
if cache_dir.exists() {
if std::fs::remove_dir_all(&cache_dir).is_ok() {
Expand All @@ -49,8 +49,3 @@ pub fn execute(all: bool) -> ExitCode {
ExitCode::IoError
}
}

fn home_dir() -> Option<std::path::PathBuf> {
#[allow(deprecated)]
std::env::home_dir()
}
2 changes: 1 addition & 1 deletion cli/src/commands/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::path::PathBuf;
pub fn execute(subcommand_str: Option<&str>) -> ExitCode {
let sub = subcommand_str.unwrap_or("show").to_lowercase();

let home = match dirs::home_dir() {
let home = match crate::dirs::home_dir() {
Some(h) => h,
None => {
eprintln!("Error: Home directory not found.");
Expand Down
12 changes: 2 additions & 10 deletions cli/src/commands/doctor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl DoctorContext {
}

fn check_cache_dirs(&mut self) {
if let Some(home) = dirs::home_dir() {
if let Some(home) = crate::dirs::home_dir() {
let config_dir = home.join(".techscript");
let cache_dir = config_dir.join("cache");
let packages_dir = config_dir.join("packages");
Expand Down Expand Up @@ -222,7 +222,7 @@ impl DoctorContext {
if self.fix && !self.overall_success {
println!("Performing automatic repair routines...");
// Auto-initialize directories
if let Some(home) = dirs::home_dir() {
if let Some(home) = crate::dirs::home_dir() {
let config_dir = home.join(".techscript");
std::fs::create_dir_all(config_dir.join("cache")).ok();
std::fs::create_dir_all(config_dir.join("packages")).ok();
Expand Down Expand Up @@ -300,11 +300,3 @@ pub fn execute(fix: bool) -> ExitCode {
ExitCode::CompilationError
}
}

mod dirs {
use std::path::PathBuf;
pub fn home_dir() -> Option<PathBuf> {
#[allow(deprecated)]
std::env::home_dir()
}
}
10 changes: 1 addition & 9 deletions cli/src/commands/repl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub fn execute() -> ExitCode {
};

// Load persistent history
let history_path = dirs::home_dir().map(|h| h.join(".techscript").join("repl_history"));
let history_path = crate::dirs::home_dir().map(|h| h.join(".techscript").join("repl_history"));
if let Some(ref path) = history_path {
std::fs::create_dir_all(path.parent().unwrap()).ok();
rl.load_history(path).ok();
Expand Down Expand Up @@ -271,11 +271,3 @@ fn dump_repl_bytecode(expr: &str) {
}
}
}

mod dirs {
use std::path::PathBuf;
pub fn home_dir() -> Option<PathBuf> {
#[allow(deprecated)]
std::env::home_dir()
}
}
10 changes: 1 addition & 9 deletions cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl ConfigManager {
let mut base = EffectiveConfig::default();

// 2. Global user config (~/.techscript/config.toml)
if let Some(home) = dirs::home_dir() {
if let Some(home) = crate::dirs::home_dir() {
let global_path = home.join(".techscript").join("config.toml");
if let Ok(content) = std::fs::read_to_string(global_path) {
if let Ok(toml_cfg) = toml::from_str::<TomlConfig>(&content) {
Expand Down Expand Up @@ -257,11 +257,3 @@ fn apply_cli(base: &mut EffectiveConfig, cli: &CliConfig) {
base.parallel_jobs = jobs;
}
}

mod dirs {
use std::path::PathBuf;
pub fn home_dir() -> Option<PathBuf> {
#[allow(deprecated)]
std::env::home_dir()
}
}
6 changes: 6 additions & 0 deletions cli/src/dirs.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use std::path::PathBuf;

pub fn home_dir() -> Option<PathBuf> {
#[allow(deprecated)]
std::env::home_dir()
}
1 change: 1 addition & 0 deletions cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub mod compile_db;
pub mod config;
pub mod crash;
pub mod diagnostics;
pub mod dirs;
pub mod events;
pub mod exit_code;
pub mod logging;
Expand Down
2 changes: 1 addition & 1 deletion cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ fn main() {
}

fn perform_first_run_check() {
if let Some(home) = dirs::home_dir() {
if let Some(home) = techscript_cli::dirs::home_dir() {
let config_dir = home.join(".techscript");
let config_file = config_dir.join("config.toml");

Expand Down
Loading