From e8cf10eee384f53707791e792e8a467cb0512f77 Mon Sep 17 00:00:00 2001 From: Overlord Date: Mon, 2 Mar 2026 20:13:38 +0100 Subject: [PATCH] Initialize project structure with basic CLI setup --- .gitignore | 9 +++++++++ Cargo.toml | 12 ++++++++++++ src/cli/flags.rs | 29 +++++++++++++++++++++++++++++ src/cli/mod.rs | 3 +++ src/lib.rs | 1 + src/main.rs | 8 ++++++++ 6 files changed, 62 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.toml create mode 100644 src/cli/flags.rs create mode 100644 src/cli/mod.rs create mode 100644 src/lib.rs create mode 100644 src/main.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..762d1bd --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +.idea/ +.vscode/ + +target/ + +Cargo.lock + +*.pdb +**/*.rs.bk diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..79ee7eb --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "pmp" +description = """\ + PHP Macro Pre-processor (PMP) \ + A php lexer, parser and macro pre-processor written in Rust. \ +""" + +version = "0.1.0-alpha" +edition = "2024" + +[dependencies] +clap = { version = "^4", features = ["derive"] } diff --git a/src/cli/flags.rs b/src/cli/flags.rs new file mode 100644 index 0000000..97760ee --- /dev/null +++ b/src/cli/flags.rs @@ -0,0 +1,29 @@ +use clap::Parser; +use std::{ + ffi::OsStr, + path::PathBuf +}; + +#[derive(Parser, Debug)] +#[command(name = "pmp", about, version)] +pub struct Args { + #[arg(long)] + php: Option, + + #[arg(long, short = 'd', hide = true)] + debug: bool, + #[arg(long, short = 'v')] + verbose: bool, + + #[arg(default_value_os = OsStr::new("."))] + files: Vec, + #[arg(last = true)] + passthrough: Vec, +} + +impl Args +{ + pub fn parse() -> Self { + ::parse() + } +} diff --git a/src/cli/mod.rs b/src/cli/mod.rs new file mode 100644 index 0000000..4539068 --- /dev/null +++ b/src/cli/mod.rs @@ -0,0 +1,3 @@ +pub mod flags; + +pub use flags::Args; diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..4f77372 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1 @@ +pub mod cli; diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..30fa7e3 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,8 @@ +use pmp::{ cli::Args }; + +fn main() +{ + let args = Args::parse(); + + println!("{:?}", args); +}