aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOndřej Čertík <ondrej@certik.us>2020-01-11 16:10:58 -0700
committerOndřej Čertík <ondrej@certik.us>2020-01-11 23:12:14 -0700
commitd326d197060c7268393efe2baf8c2e5358c0f385 (patch)
tree235a66edb78eefbe845446d4bb8120db3d283b4a
parente4881118047be41a27e15ce98a18141eac028809 (diff)
downloadfpm-d326d197060c7268393efe2baf8c2e5358c0f385.tar.gz
fpm-d326d197060c7268393efe2baf8c2e5358c0f385.zip
List f90 in the current directory
-rw-r--r--.gitlab-ci.yml4
-rw-r--r--src/main.rs39
2 files changed, 36 insertions, 7 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 09e53ff..d1a4cae 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -7,8 +7,8 @@ rust-latest:
script:
- cargo build --verbose
- cargo test --verbose
- - cargo run -- -h
- - cargo run -- s 5
+ - touch a.f90 b.f90 c.f90
+ - cargo run -- build
rust-nightly:
stage: build
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<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");
+ }
}