diff --git a/BUILD b/BUILD new file mode 100644 index 00000000..e69de29b diff --git a/Cargo.lock b/Cargo.lock index 951d56ca..b0a01369 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9,6 +9,13 @@ dependencies = [ "pretty_assertions", ] +[[package]] +name = "committer_cli" +version = "0.1.0-rc.0" +dependencies = [ + "pretty_assertions", +] + [[package]] name = "diff" version = "0.1.13" diff --git a/Cargo.toml b/Cargo.toml index c0cc4700..a01be854 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ # https://doc.rust-lang.org/cargo/reference/resolver.html#feature-resolver-version-2 resolver = "2" -members = ["crates/committer"] +members = ["crates/committer", "crates/committer_cli"] [workspace.package] version = "0.1.0-rc.0" diff --git a/WORKSPACE b/WORKSPACE new file mode 100644 index 00000000..e69de29b diff --git a/crates/committer_cli/BUILD b/crates/committer_cli/BUILD new file mode 100644 index 00000000..3b5d6c45 --- /dev/null +++ b/crates/committer_cli/BUILD @@ -0,0 +1,12 @@ +# To be used together with a bazel WORKSPACE file that contains the following definitions. +load("@committer_crate//:defs.bzl", "all_crate_deps") +load("@rules_rust//rust:defs.bzl", "rust_binary") + +rust_binary( + name="committer_exe", + srcs=glob(["src/**/*.rs"]), + visibility=["//visibility:public"], + deps=all_crate_deps(), + proc_macro_deps=all_crate_deps(proc_macro=True), + edition="2021", +) diff --git a/crates/committer_cli/Cargo.toml b/crates/committer_cli/Cargo.toml new file mode 100644 index 00000000..f73c7a51 --- /dev/null +++ b/crates/committer_cli/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "committer_cli" +version.workspace = true +edition.workspace = true +repository.workspace = true +license-file.workspace = true +description = "Cli for the committer package." + +[lints] +workspace = true + +[dev-dependencies] +pretty_assertions.workspace = true diff --git a/crates/committer_cli/src/main.rs b/crates/committer_cli/src/main.rs new file mode 100644 index 00000000..d6a3c5ff --- /dev/null +++ b/crates/committer_cli/src/main.rs @@ -0,0 +1,20 @@ +use std::env; +use std::path::Path; + +/// Main entry point of the committer CLI. +fn main() { + // Open the input file. + let args: Vec = env::args().collect(); + let input_file_name = Path::new(&args[1]); + let output_file_name = Path::new(&args[2]); + assert!( + input_file_name.is_absolute() && output_file_name.is_absolute(), + "Given paths must be absolute" + ); + + // Business logic to be implemented here. + let output = std::fs::read(input_file_name).unwrap(); + + // Output to file. + std::fs::write(output_file_name, output).expect("Failed to write output"); +}