<svg version="1.1" width="16" height="16" viewBox="0 0 16 16" class="" aria-hidden="true" data-component="Octicon" aria-label="undefined"><path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path></svg> Raw
<svg version="1.1" width="16" height="16" viewBox="0 0 16 16" class="" aria-hidden="true" data-component="Octicon" aria-label="undefined"><path d="m.427 1.927 1.215 1.215a8.002 8.002 0 1 1-1.6 5.685.75.75 0 1 1 1.493-.154 6.5 6.5 0 1 0 1.18-4.458l1.358 1.358A.25.25 0 0 1 3.896 6H.25A.25.25 0 0 1 0 5.75V2.104a.25.25 0 0 1 .427-.177ZM7.75 4a.75.75 0 0 1 .75.75v2.992l2.028.812a.75.75 0 0 1-.557 1.392l-2.5-1A.751.751 0 0 1 7 8.25v-3.5A.75.75 0 0 1 7.75 4Z"></path></svg> History
<svg version="1.1" width="16" height="16" viewBox="0 0 16 16" class="" aria-hidden="true" data-component="Octicon" aria-label="undefined"><path d="M2.75 14A1.75 1.75 0 0 1 1 12.25v-2.5a.75.75 0 0 1 1.5 0v2.5c0 .138.112.25.25.25h10.5a.25.25 0 0 0 .25-.25v-2.5a.75.75 0 0 1 1.5 0v2.5A1.75 1.75 0 0 1 13.25 14Z"></path><path d="M7.25 7.689V2a.75.75 0 0 1 1.5 0v5.689l1.97-1.969a.749.749 0 1 1 1.06 1.06l-3.25 3.25a.749.749 0 0 1-1.06 0L4.22 6.78a.749.749 0 1 1 1.06-1.06l1.97 1.969Z"></path></svg> Download
| 1 | from __future__ import annotations |
| 2 | |
| 3 | import argparse |
| 4 | import pathlib |
| 5 | |
| 6 | |
| 7 | def count(text: str) -> dict[str, int]: |
| 8 | return {'lines': len(text.splitlines()), 'words': len(text.split()), 'characters': len(text)} |
| 9 | |
| 10 | |
| 11 | def main() -> int: |
| 12 | parser = argparse.ArgumentParser() |
| 13 | parser.add_argument('path', type=pathlib.Path) |
| 14 | args = parser.parse_args() |
| 15 | for key, value in count(args.path.read_text(encoding='utf-8')).items(): |
| 16 | print(key + ': ' + str(value)) |
| 17 | return 0 |
| 18 | |
| 19 | |
| 20 | if __name__ == '__main__': |
| 21 | raise SystemExit(main()) |
| 22 |