parent
18fbbe532a
commit
201d674da1
16
src/main.rs
16
src/main.rs
|
@ -2,6 +2,7 @@ use std::path::{Path, PathBuf};
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
|
||||||
use cli::{Cli, Command};
|
use cli::{Cli, Command};
|
||||||
|
use errors::anyhow;
|
||||||
use utils::net::{get_available_port, port_is_available};
|
use utils::net::{get_available_port, port_is_available};
|
||||||
|
|
||||||
use clap::{CommandFactory, Parser};
|
use clap::{CommandFactory, Parser};
|
||||||
|
@ -13,10 +14,17 @@ mod messages;
|
||||||
mod prompt;
|
mod prompt;
|
||||||
|
|
||||||
fn get_config_file_path(dir: &Path, config_path: &Path) -> (PathBuf, PathBuf) {
|
fn get_config_file_path(dir: &Path, config_path: &Path) -> (PathBuf, PathBuf) {
|
||||||
let root_dir = dir
|
let root_dir = dir.ancestors().find(|a| a.join(config_path).exists()).unwrap_or_else(|| {
|
||||||
.ancestors()
|
messages::unravel_errors(
|
||||||
.find(|a| a.join(config_path).exists())
|
"",
|
||||||
.unwrap_or_else(|| panic!("could not find directory containing config file"));
|
&anyhow!(
|
||||||
|
"{} not found in current directory or ancestors, current_dir is {}",
|
||||||
|
config_path.display(),
|
||||||
|
dir.display()
|
||||||
|
),
|
||||||
|
);
|
||||||
|
std::process::exit(1);
|
||||||
|
});
|
||||||
|
|
||||||
// if we got here we found root_dir so config file should exist so we can unwrap safely
|
// if we got here we found root_dir so config file should exist so we can unwrap safely
|
||||||
let config_file = root_dir
|
let config_file = root_dir
|
||||||
|
|
Loading…
Reference in New Issue