mirror of
https://github.com/sharkdp/bat
synced 2024-11-04 18:00:24 +00:00
Add proper CLI
This commit is contained in:
parent
78a681f027
commit
a70efae79b
@ -5,6 +5,7 @@ import glob
|
|||||||
import sys
|
import sys
|
||||||
import os.path as path
|
import os.path as path
|
||||||
import os
|
import os
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
|
||||||
BAT_OPTIONS = [
|
BAT_OPTIONS = [
|
||||||
@ -16,7 +17,7 @@ BAT_OPTIONS = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def create_highlighted_versions():
|
def create_highlighted_versions(output_basepath):
|
||||||
root = os.path.dirname(os.path.abspath(__file__))
|
root = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
||||||
for source in glob.glob(path.join(root, "source", "*", "*")):
|
for source in glob.glob(path.join(root, "source", "*", "*")):
|
||||||
@ -28,7 +29,7 @@ def create_highlighted_versions():
|
|||||||
source_dirname = path.basename(path.dirname(source))
|
source_dirname = path.basename(path.dirname(source))
|
||||||
source_filename = path.basename(source)
|
source_filename = path.basename(source)
|
||||||
|
|
||||||
output_dir = path.join(root, "highlighted", source_dirname)
|
output_dir = path.join(output_basepath, source_dirname)
|
||||||
output_path = path.join(output_dir, source_filename)
|
output_path = path.join(output_dir, source_filename)
|
||||||
|
|
||||||
os.makedirs(output_dir, exist_ok=True)
|
os.makedirs(output_dir, exist_ok=True)
|
||||||
@ -55,4 +56,19 @@ def create_highlighted_versions():
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
create_highlighted_versions()
|
parser = argparse.ArgumentParser(
|
||||||
|
description="This script creates syntax-highlighted versions of all "
|
||||||
|
"files in the 'source' directory."
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--output",
|
||||||
|
"-O",
|
||||||
|
metavar="PATH",
|
||||||
|
help="Output directory",
|
||||||
|
required=True,
|
||||||
|
type=str,
|
||||||
|
)
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
create_highlighted_versions(output_basepath=args.output)
|
||||||
|
Loading…
Reference in New Issue
Block a user