From d326d197060c7268393efe2baf8c2e5358c0f385 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C4=8Cert=C3=ADk?= Date: Sat, 11 Jan 2020 16:10:58 -0700 Subject: List f90 in the current directory --- src/main.rs | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index 4277e8c..85ba64a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,14 +2,43 @@ use structopt::StructOpt; #[derive(Debug, StructOpt)] struct Cli { - /// The pattern to look for - pattern: String, - /// The path to the file to read - #[structopt(parse(from_os_str))] - path: std::path::PathBuf, + /// fpm command + command: String, +} + +fn collect_source_files() -> Vec { + let mut files: Vec = 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"); + } } -- cgit v1.2.3