Merge branch 'main' into interactive-mode

This commit is contained in:
sreedev
2023-01-09 22:55:14 -05:00
10 changed files with 250 additions and 102 deletions

View File

@@ -1,7 +1,7 @@
use std::path::PathBuf;
use std::{fs, path::PathBuf};
use anyhow::{anyhow, Result};
use clap::Parser;
use anyhow::Result;
use std::fs;
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
@@ -22,20 +22,17 @@ pub struct Params {
impl Params {
pub fn get_directory(&self) -> Result<String> {
let dir_string: String = self
let dir_pathbuf: PathBuf = self
.dir
.clone()
.unwrap_or(std::env::current_dir()?)
.as_os_str()
.to_str()
.unwrap()
.to_string();
.into();
let dir_pathbuf = PathBuf::from(&dir_string);
let dir = fs::canonicalize(&dir_pathbuf)?
let dir = fs::canonicalize(dir_pathbuf)?
.as_os_str()
.to_str()
.unwrap()
.ok_or_else(|| anyhow!("Invalid directory"))?
.to_string();
Ok(dir)