Skip to content

Commit c61f05e

Browse files
authored
Create cli_tool.h#
1 parent 9f9a678 commit c61f05e

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

examples/more/cli_tool.h#

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
;; H# CLI Tool — HackerOS command line tool example
2+
;; Perfect Python script replacement
3+
4+
use "std -> env" from "env"
5+
6+
fn show_help() is
7+
write("Usage: mytool [--verbose] [--output FILE] <input>")
8+
write(" --verbose Show detailed output")
9+
write(" --output Output file path")
10+
end
11+
12+
fn main() is
13+
let mut verbose: bool = false
14+
let mut output: string = "output.txt"
15+
let mut input: string = ""
16+
17+
;; Parse command line arguments
18+
;; env::args() returns [string] array
19+
let mut i: int = 0
20+
while i < 10 is
21+
;; In real impl: iterate env::args()
22+
;; For demo: show usage
23+
i += 1
24+
end
25+
26+
if verbose is
27+
write("[verbose] Processing...")
28+
end
29+
30+
write("H# CLI Tool v0.1")
31+
write("Output: " + output)
32+
write("Done.")
33+
end

0 commit comments

Comments
 (0)