1
Fork 0

Add a struct to store compose projects

This commit is contained in:
Jake Howard 2020-10-05 17:36:44 +01:00
parent efffe24d62
commit 8de8767b13
Signed by: jake
GPG key ID: 57AFB45680EDD477
2 changed files with 30 additions and 1 deletions

13
src/compose.rs Normal file
View file

@ -0,0 +1,13 @@
use std::path::PathBuf;
pub struct ComposeProject {
compose_file: PathBuf,
}
impl ComposeProject {
pub fn new(compose_file: &PathBuf) -> ComposeProject {
ComposeProject {
compose_file: compose_file.to_owned(),
}
}
}

View file

@ -1,7 +1,10 @@
use glob::glob;
use std::path::PathBuf;
use std::process::exit;
use structopt::StructOpt;
mod compose;
#[derive(StructOpt, Debug)]
#[structopt()]
struct Opt {
@ -24,5 +27,18 @@ fn get_files(files: &[String]) -> Option<Vec<PathBuf>> {
fn main() {
let opts = Opt::from_args();
println!("{:?}", get_files(&opts.files));
if opts.files.is_empty() {
println!("Must specify some files");
exit(1);
}
let compose_files = match get_files(&opts.files) {
Some(f) => f,
None => exit(1),
};
let compose_projects: Vec<compose::ComposeProject> = compose_files
.iter()
.map(compose::ComposeProject::new)
.collect();
println!("Found {} projects", compose_projects.len());
}