Skip to content

Commit b25b443

Browse files
committed
chore: adjust README
1 parent 8076815 commit b25b443

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

Cli/Example.lean

+14-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ def runExampleCmd (p : Parsed) : IO UInt32 := do
1818
let priority : Nat := p.flag! "priority" |>.as! Nat
1919
IO.println <| "Flag `--priority` always has at least a default value: " ++ toString priority
2020

21+
if p.hasFlag "module" then
22+
let moduleName : ModuleName := p.flag! "module" |>.as! ModuleName
23+
IO.println <| s!"Flag `--module` was set to `{moduleName}`."
24+
2125
if let some setPathsFlag := p.flag? "set-paths" then
2226
IO.println <| toString <| setPathsFlag.as! (Array String)
2327
return 0
@@ -43,6 +47,9 @@ def exampleCmd : Cmd := `[Cli|
4347
o, optimize; "Declares a flag `--optimize` with an associated short alias `-o`."
4448
p, priority : Nat; "Declares a flag `--priority` with an associated short alias `-p` " ++
4549
"that takes an argument of type `Nat`."
50+
module : ModuleName; "Declares a flag `--module` that takes an argument of type `ModuleName` " ++
51+
"which be used to reference Lean modules like `Init.Data.Array` " ++
52+
"or Lean files using a relative path like `Init/Data/Array.lean`."
4653
"set-paths" : Array String; "Declares a flag `--set-paths` " ++
4754
"that takes an argument of type `Array Nat`. " ++
4855
"Quotation marks allow the use of hyphens."
@@ -68,14 +75,15 @@ def exampleCmd : Cmd := `[Cli|
6875
def main (args : List String) : IO UInt32 :=
6976
exampleCmd.validate args
7077

71-
#eval main <| "-i -o -p 1 --set-paths=path1,path2,path3 input output1 output2".splitOn " "
78+
#eval main <| "-i -o -p 1 --module=Lean.Compiler --set-paths=path1,path2,path3 input output1 output2".splitOn " "
7279
/-
7380
Yields:
7481
Input: input
7582
Outputs: #[output1, output2]
7683
Flag `--invert` was set.
7784
Flag `--optimize` was set.
7885
Flag `--priority` always has at least a default value: 1
86+
Flag `--module` was set to `Lean.Compiler`.
7987
#[path1, path2, path3]
8088
-/
8189

@@ -121,6 +129,11 @@ Yields:
121129
-p, --priority : Nat Declares a flag `--priority` with an associated
122130
short alias `-p` that takes an argument of type
123131
`Nat`. [Default: `0`]
132+
--module : ModuleName Declares a flag `--module` that takes an
133+
argument of type `ModuleName` which be used to
134+
reference Lean modules like `Init.Data.Array` or
135+
Lean files using a relative path like
136+
`Init/Data/Array.lean`.
124137
--set-paths : Array String Declares a flag `--set-paths` that takes an
125138
argument of type `Array Nat`. Quotation marks
126139
allow the use of hyphens.

README.md

+15-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ See [the documentation of Lake](https://github.com/leanprover/lake).
55
Use one of the following for the `<tag>` in the dependency source `Source.git "https://github.com/mhuisi/lean4-cli.git" "<tag>"`:
66
- `main` if you want to stay in sync with Lean 4 milestone releases. The `main` branch will contain a working version of lean4-cli for the most recent Lean 4 milestone.
77
- `nightly` if you want to stay in sync with Lean 4 nightly releases. The `nightly` branch will contain a working version of lean4-cli for the most recent Lean 4 nightly build.
8-
- One of the specific release tags if you want to pin a specific version, e.g. `v1.0.0-lv4.0.0-m4` for v1.0.0 for the 4th Lean 4 milestone release or `v1.0.0-lnightly-2022-05-21` for v1.0.0 for the Lean 4 nightly version from 2022-05-21. Only nightlies where lean4-cli broke will receive a release tag.
8+
- One of the specific release tags if you want to pin a specific version, e.g. `v1.0.0-lv4.0.0-m5` for v1.0.0 for the 5th Lean 4 milestone release or `v1.0.0-lnightly-2023-08-15` for v1.0.0 for the Lean 4 nightly version from 2023-08-15.
99

1010
### Configuration
1111
Commands are configured with a lightweight DSL. The following declarations define a command `exampleCmd` with two subcommands `installCmd` and `testCmd`. `runExampleCmd` denotes a handler that is called when the command is run and is described further down below in the **Command Handlers** subsection.
@@ -34,6 +34,9 @@ def exampleCmd : Cmd := `[Cli|
3434
o, optimize; "Declares a flag `--optimize` with an associated short alias `-o`."
3535
p, priority : Nat; "Declares a flag `--priority` with an associated short alias `-p` " ++
3636
"that takes an argument of type `Nat`."
37+
module : ModuleName; "Declares a flag `--module` that takes an argument of type `ModuleName` " ++
38+
"which be used to reference Lean modules like `Init.Data.Array` " ++
39+
"or Lean files using a relative path like `Init/Data/Array.lean`."
3740
"set-paths" : Array String; "Declares a flag `--set-paths` " ++
3841
"that takes an argument of type `Array Nat`. " ++
3942
"Quotation marks allow the use of hyphens."
@@ -77,6 +80,10 @@ def runExampleCmd (p : Parsed) : IO UInt32 := do
7780
let priority : Nat := p.flag! "priority" |>.as! Nat
7881
IO.println <| "Flag `--priority` always has at least a default value: " ++ toString priority
7982
83+
if p.hasFlag "module" then
84+
let moduleName : ModuleName := p.flag! "module" |>.as! ModuleName
85+
IO.println <| s!"Flag `--module` was set to `{moduleName}`."
86+
8087
if let some setPathsFlag := p.flag? "set-paths" then
8188
IO.println <| toString <| setPathsFlag.as! (Array String)
8289
return 0
@@ -89,14 +96,15 @@ Below you can find some simple examples of how to pass user input to the Cli lib
8996
def main (args : List String) : IO UInt32 :=
9097
exampleCmd.validate args
9198
92-
#eval main <| "-i -o -p 1 --set-paths=path1,path2,path3 input output1 output2".splitOn " "
99+
#eval main <| "-i -o -p 1 --module=Lean.Compiler --set-paths=path1,path2,path3 input output1 output2".splitOn " "
93100
/-
94101
Yields:
95102
Input: input
96103
Outputs: #[output1, output2]
97104
Flag `--invert` was set.
98105
Flag `--optimize` was set.
99106
Flag `--priority` always has at least a default value: 1
107+
Flag `--module` was set to `Lean.Compiler`.
100108
#[path1, path2, path3]
101109
-/
102110
@@ -143,6 +151,11 @@ FLAGS:
143151
-p, --priority : Nat Declares a flag `--priority` with an associated
144152
short alias `-p` that takes an argument of type
145153
`Nat`. [Default: `0`]
154+
--module : ModuleName Declares a flag `--module` that takes an
155+
argument of type `ModuleName` which be used to
156+
reference Lean modules like `Init.Data.Array` or
157+
Lean files using a relative path like
158+
`Init/Data/Array.lean`.
146159
--set-paths : Array String Declares a flag `--set-paths` that takes an
147160
argument of type `Array Nat`. Quotation marks
148161
allow the use of hyphens.

0 commit comments

Comments
 (0)