Add a struct to store compose projects
This commit is contained in:
parent
efffe24d62
commit
8de8767b13
2 changed files with 30 additions and 1 deletions
13
src/compose.rs
Normal file
13
src/compose.rs
Normal 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(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
18
src/main.rs
18
src/main.rs
|
@ -1,7 +1,10 @@
|
||||||
use glob::glob;
|
use glob::glob;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
use std::process::exit;
|
||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
|
|
||||||
|
mod compose;
|
||||||
|
|
||||||
#[derive(StructOpt, Debug)]
|
#[derive(StructOpt, Debug)]
|
||||||
#[structopt()]
|
#[structopt()]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
|
@ -24,5 +27,18 @@ fn get_files(files: &[String]) -> Option<Vec<PathBuf>> {
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let opts = Opt::from_args();
|
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());
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue