From 6cb60c7eb9894490370510d490faa24fd987b248 Mon Sep 17 00:00:00 2001 From: Usairim Isani Date: Sun, 4 Oct 2020 15:54:07 +0500 Subject: [PATCH] refactor : has module uses profile impl. --- src/has.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/has.rs b/src/has.rs index a5a52db..330648a 100644 --- a/src/has.rs +++ b/src/has.rs @@ -17,7 +17,8 @@ * along with this program. If not, see . */ -use crate::utils::{find_profile, get_name1, ColoredText}; +use crate::profile::{Profile, ProfileFlags}; +use crate::utils::ColoredText; use clap::ArgMatches; use log::debug; use std::process::exit; @@ -27,16 +28,16 @@ pub fn start(cli: &ArgMatches<'_>) { debug!("subcommand: has"); let profile_name = cli.value_of("PROFILE_NAME").unwrap(); - - if let Some(profile) = find_profile(&get_name1(profile_name)) { + let flags = ProfileFlags::default_with(ProfileFlags::READ); + if let Ok(profile) = Profile::new(profile_name, flags) { println!( - "Found profile for {} at {}.", - profile_name, - ColoredText::new(Color::Green, &profile.to_string_lossy()) + "Found Profile for {} at {}.", + profile.raw_name(), + ColoredText::new(Color::Green, &profile.path().unwrap().to_string_lossy()) ); exit(0); } else { - println!("Cloud not find a profile for {}.", profile_name); + println!("Could not find a Profile for {}.", profile_name); exit(100); } }