1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

chgrp: split the functions into two

This commit is contained in:
Sylvestre Ledru 2025-01-19 23:22:55 +01:00
parent 9c42b8efdc
commit 4c3e9c893a

View file

@ -37,8 +37,8 @@ fn parse_gid_from_str(group: &str) -> Result<u32, String> {
}
}
fn parse_gid_and_uid(matches: &ArgMatches) -> UResult<GidUidOwnerFilter> {
let mut raw_group: String = String::new();
fn get_dest_gid(matches: &ArgMatches) -> UResult<(Option<u32>, String)> {
let mut raw_group = String::new();
let dest_gid = if let Some(file) = matches.get_one::<String>(options::REFERENCE) {
fs::metadata(file)
.map(|meta| {
@ -62,6 +62,11 @@ fn parse_gid_and_uid(matches: &ArgMatches) -> UResult<GidUidOwnerFilter> {
}
}
};
Ok((dest_gid, raw_group))
}
fn parse_gid_and_uid(matches: &ArgMatches) -> UResult<GidUidOwnerFilter> {
let (dest_gid, raw_group) = get_dest_gid(matches)?;
// Handle --from option
let filter = if let Some(from_group) = matches.get_one::<String>(options::FROM) {