Skip to content

Commit

Permalink
Merge pull request #63 from Seasawher/Seasawher/issue61
Browse files Browse the repository at this point in the history
count characters in markdown files
  • Loading branch information
Seasawher authored Jan 2, 2025
2 parents 41b1dbd + 74fcb1e commit 1cf455f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion Mdgen/Cli.lean
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ def runMdgenCmd (p : Parsed) : IO UInt32 := do

let paths ← getLeanFilePaths inputDir

if p.hasFlag "count" then
let mut globalCount := 0
for path in paths do
let content ← IO.FS.lines path
let count := content.foldl (fun acc str => acc + str.length) 0
globalCount := globalCount + count
IO.println s!"The input Lean files contain a total of {globalCount} characters."

for path in paths do
let content ← IO.FS.lines path

Expand All @@ -25,9 +33,12 @@ def runMdgenCmd (p : Parsed) : IO UInt32 := do

/-- API definition of `mdgen` command -/
def mkMdgenCmd : Cmd := `[Cli|
mdgen VIA runMdgenCmd; ["1.5.0"]
mdgen VIA runMdgenCmd; ["1.6.0"]
"mdgen is a tool to generate .md files from .lean files."

FLAGS:
c, count; "Counts the total number of characters in the input files. However, please be aware that the output may not be entirely accurate."

ARGS:
input_dir : String; "The directory containing the input Lean files."
output_dir : String; "The directory to write the markdown files."
Expand Down
2 changes: 1 addition & 1 deletion lakefile.lean
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Lake
open Lake DSL

package «mdgen» where
version := v!"1.5.0"
version := v!"1.6.0"
keywords := #["cli", "markdown"]
description := "Tool to generate markdown files from lean files."

Expand Down

0 comments on commit 1cf455f

Please sign in to comment.