-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
47 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,4 @@ pub mod update; | |
pub mod utils; | ||
pub mod why; | ||
|
||
pub use utils::package_spec_list; | ||
pub use utils::PackageSpecList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,30 @@ | ||
use std::fmt::Display; | ||
|
||
use clap::parser::ArgMatches; | ||
use ion::PackageSpec; | ||
|
||
pub fn package_spec_list(matches: &ArgMatches) -> String { | ||
let packages = matches.get_many::<String>("PACKAGE").into_iter().flatten(); | ||
pub struct PackageSpecList { | ||
pub list: Vec<PackageSpec>, | ||
} | ||
|
||
impl PackageSpecList { | ||
pub fn new(matches: &ArgMatches) -> Self { | ||
let packages = matches | ||
.get_many::<String>("PACKAGE").into_iter().flatten(); | ||
Self { | ||
list: packages | ||
.map(PackageSpec::new) | ||
.collect::<Vec<_>>(), | ||
} | ||
} | ||
} | ||
|
||
packages | ||
.map(PackageSpec::new) | ||
.map(|p| format!("{p}")) | ||
.collect::<Vec<_>>() | ||
.join(",") | ||
impl Display for PackageSpecList { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
if self.list.len() == 0 { | ||
write!(f, "") | ||
} else { | ||
write!(f, "[{}]", self.list.iter().map(|p| format!("{p}")).collect::<Vec<_>>().join(",")) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters