aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
blob: 85ba64a4e67476ec974ef93bdda961f171f0e987 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use structopt::StructOpt;

#[derive(Debug, StructOpt)]
struct Cli {
    /// fpm command
    command: String,
}

fn collect_source_files() -> Vec<std::path::PathBuf> {
    let mut files: Vec<std::path::PathBuf> = Vec::new();
    for entry in std::fs::read_dir(".").unwrap() {
        let entry = entry.unwrap();
        let path = entry.path();
        if !path.is_dir() {
            let ext = match path.extension() {
                None => "None",
                Some(ext) => ext.to_str().unwrap(),
            };
            if ext == "f90" {
                files.push(path);
            }
        }
    }
    files
}

fn build() {
    let files = collect_source_files();
    for file in &files {
        println!("File: {}", file.to_str().unwrap());
    }
    println!("Files: {:?}", files);
}

fn main() {
    let args = Cli::from_args();
    println!("{:?}", args);
    if args.command == "build" {
        println!("Command: build");
        build();
    } else {
        panic!("Unknown command");
    }
}