Skip to content

Commit

Permalink
refactor : rm mod uses new profile impl. (#14)
Browse files Browse the repository at this point in the history
* refactor : rm mod uses new profile impl.

* efactor : rm mod uses new profile impl.

Co-authored-by: rusty-snake <[email protected]>

Co-authored-by: rusty-snake <[email protected]>
  • Loading branch information
UsairimIsani and rusty-snake authored Sep 15, 2020
1 parent e58d03e commit d7f116a
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/rm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

use crate::{profile_path, utils::get_name1};
use crate::profile::{Profile, ProfileFlags};
use clap::ArgMatches;
use log::{debug, error, trace};
use std::fs::remove_file;
Expand All @@ -27,9 +27,13 @@ pub fn start(cli: &ArgMatches<'_>) {

let profiles = cli.values_of("PROFILE_NAMES").unwrap();
for profile in profiles {
let profile = get_name1(profile);
trace!("Deleting '{}'.", profile);
remove_file(profile_path!(USER / &profile))
.unwrap_or_else(|err| error!("Failed to delete '{}': {}", profile, err));
let profile = Profile::new(
profile,
ProfileFlags::LOOKUP_USER | ProfileFlags::DENY_BY_PATH | ProfileFlags::ASSUME_EXISTENCE,
)
.unwrap();
trace!("Deleting '{}'.", profile.full_name());
remove_file(profile.path().unwrap())
.unwrap_or_else(|err| error!("Failed to delete '{}': {}", profile.full_name(), err));
}
}

0 comments on commit d7f116a

Please sign in to comment.