Implement robust and type-safe configuration handling to avoid fragile hardcoding and improve maintainability. Key guidelines:

  1. Use type-safe structures for passing configuration between processes instead of raw strings
  2. Avoid hardcoding environment paths or configuration values
  3. Use environment variables through a centralized configuration system
  4. Validate configuration values at startup

Example of improved configuration handling:

// Instead of this:
let docs = env::args_os().nth(1).expect("doc path should be first argument");
let docs = env::current_dir().unwrap().join(docs);

// Do this:
#[derive(Parser)]
struct Config {
    docs: PathBuf,
    #[clap(long)]
    link_targets_dir: Vec<PathBuf>,
}

let config = Config::parse();
let docs = config.docs.canonicalize()?;

This approach: