aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOndřej Čertík <ondrej@certik.us>2020-01-11 15:00:15 -0700
committerOndřej Čertík <ondrej@certik.us>2020-01-11 15:08:22 -0700
commitdbad76baac9911d692ebc78335cbc51554443344 (patch)
tree401b67006c5df6f81ab3d4e6a81c26c242b6c106
parent910072d4875f4b0bb57e547990cf26c541460fcc (diff)
downloadfpm-dbad76baac9911d692ebc78335cbc51554443344.tar.gz
fpm-dbad76baac9911d692ebc78335cbc51554443344.zip
Parse command line arguments
-rw-r--r--.gitlab-ci.yml2
-rw-r--r--Cargo.toml1
-rw-r--r--src/main.rs14
3 files changed, 15 insertions, 2 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index cb84891..04b81b1 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -6,7 +6,7 @@ rust-latest:
image: rust:latest
script:
- cargo build --verbose
- - cargo run
+ - cargo run -- s 5
- cargo test --verbose
rust-nightly:
diff --git a/Cargo.toml b/Cargo.toml
index a7cf602..868f563 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -7,3 +7,4 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
+structopt = "0.3.7"
diff --git a/src/main.rs b/src/main.rs
index e7a11a9..4277e8c 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,3 +1,15 @@
+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,
+}
+
fn main() {
- println!("Hello, world!");
+ let args = Cli::from_args();
+ println!("{:?}", args);
}