Skip to content

Commit

Permalink
refactor : has module uses profile impl.
Browse files Browse the repository at this point in the history
  • Loading branch information
UsairimIsani committed Oct 4, 2020
1 parent d7f116a commit 6cb60c7
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/has.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

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;
Expand All @@ -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);
}
}

0 comments on commit 6cb60c7

Please sign in to comment.