@@ -49,6 +49,30 @@ fn compile(input_path: &str, dev: bool) -> (bool, Vec<PathBuf>) {
4949 (has_errors, result.included_files)
5050}
5151
52+fn print_help() {
53+ eprintln!(
54+ "\
55+htmlang {} - a minimalist layout language that compiles to static HTML
56+
57+Usage: htmlang [options] <file.hl>
58+
59+Options:
60+ -w, --watch Watch for changes and recompile
61+ -s, --serve Start dev server with hot reload (implies --watch)
62+ -p, --port <N> Port for dev server (default: 3000)
63+ -d, --dev Development mode
64+ -h, --help Show this help
65+ -V, --version Show version
66+
67+Examples:
68+ htmlang page.hl Compile page.hl to page.html
69+ htmlang -w page.hl Recompile on file changes
70+ htmlang -s page.hl Start dev server with hot reload
71+ htmlang -s -p 8080 page.hl",
72+ env!("CARGO_PKG_VERSION")
73+ );
74+}
75+
5276fn main() {
5377 let args: Vec<String> = env::args().collect();
5478 let mut watch = false;
@@ -60,6 +84,14 @@ fn main() {
6084 let mut i = 1;
6185 while i < args.len() {
6286 match args[i].as_str() {
87+ "--help" | "-h" => {
88+ print_help();
89+ process::exit(0);
90+ }
91+ "--version" | "-V" => {
92+ println!("htmlang {}", env!("CARGO_PKG_VERSION"));
93+ process::exit(0);
94+ }
6395 "--watch" | "-w" => watch = true,
6496 "--dev" | "-d" => dev = true,
6597 "--serve" | "-s" => {
@@ -93,7 +125,7 @@ fn main() {
93125 let input_path = match input_path {
94126 Some(p) => p,
95127 None => {
96− eprintln!("Usage: htmlang [--watch] [--serve [--port N]] [--dev] <file.hl>");
128+ print_help();
97129 process::exit(1);
98130 }
99131 };