-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from Seasawher/Seasawher/issue32
use Cli tool for Lean
- Loading branch information
Showing
6 changed files
with
65 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
import Mdgen.Main | ||
import Mdgen.Cli | ||
|
||
|
||
def main (args : List String) : IO UInt32 := | ||
mkMdgenCmd.validate args |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import Mdgen.File | ||
import Mdgen.ConvertToMd | ||
import Cli | ||
|
||
open Cli System | ||
|
||
def runMdgenCmd (p : Parsed) : IO UInt32 := do | ||
let inputDir : FilePath := p.positionalArg! "input_dir" |>.as! String | ||
let outputDir : FilePath := p.positionalArg! "output_dir" |>.as! String | ||
|
||
let paths ← getLeanFilePaths inputDir | ||
|
||
for path in paths do | ||
let mut content ← IO.FS.lines path | ||
content := content.map (fun line => line.replace "\r" "") | ||
|
||
let outputFilePath := outputFilePath | ||
inputDir.components | ||
outputDir.components | ||
path.components | ||
|
||
createFile (genPath outputFilePath) (convertToMd content.toList) | ||
return 0 | ||
|
||
def mkMdgenCmd : Cmd := `[Cli| | ||
mkMdgenCmd VIA runMdgenCmd; ["1.4.0"] | ||
"mdgen is a tool to generate .md files from .lean files." | ||
|
||
ARGS: | ||
input_dir : String; "The directory containing the input Lean files." | ||
output_dir : String; "The directory to write the markdown files." | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,15 @@ | ||
{"version": "1.1.0", | ||
"packagesDir": ".lake/packages", | ||
"packages": [], | ||
"packages": | ||
[{"url": "https://github.com/leanprover/lean4-cli.git", | ||
"type": "git", | ||
"subDir": null, | ||
"scope": "", | ||
"rev": "2cf1030dc2ae6b3632c84a09350b675ef3e347d0", | ||
"name": "Cli", | ||
"manifestFile": "lake-manifest.json", | ||
"inputRev": "main", | ||
"inherited": false, | ||
"configFile": "lakefile.toml"}], | ||
"name": "mdgen", | ||
"lakeDir": ".lake"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters