mirror of
https://github.com/sharkdp/bat.git
synced 2025-04-18 16:50:33 +01:00
Make generate_snapshots script more robust
This commit is contained in:
parent
3e21d69a92
commit
b4c6e412dc
@ -1,9 +1,11 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import itertools
|
import itertools
|
||||||
import subprocess
|
import subprocess
|
||||||
import pathlib
|
import pathlib
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
|
|
||||||
def generate_snapshots():
|
def generate_snapshots():
|
||||||
single_styles = ["changes", "grid", "header", "numbers"]
|
single_styles = ["changes", "grid", "header", "numbers"]
|
||||||
collective_styles = ["full", "plain"]
|
collective_styles = ["full", "plain"]
|
||||||
@ -22,33 +24,41 @@ def generate_snapshots():
|
|||||||
generate_snapshot("tabs_8", "--tabs=8 --style=full --wrap=never")
|
generate_snapshot("tabs_8", "--tabs=8 --style=full --wrap=never")
|
||||||
generate_snapshot("tabs_8_wrapped", "--tabs=8 --style=full --wrap=character")
|
generate_snapshot("tabs_8_wrapped", "--tabs=8 --style=full --wrap=character")
|
||||||
|
|
||||||
|
|
||||||
def generate_style_snapshot(style):
|
def generate_style_snapshot(style):
|
||||||
generate_snapshot(style.replace(",","_"), "--style={}".format(style))
|
generate_snapshot(style.replace(",", "_"), "--style={}".format(style))
|
||||||
|
|
||||||
|
|
||||||
def generate_snapshot(name, arguments):
|
def generate_snapshot(name, arguments):
|
||||||
command = "../../target/debug/bat --decorations=always {1} sample.rs > output/{0}.snapshot.txt".format(
|
command = "cargo run -- --paging=never --color=never --decorations=always "
|
||||||
name,
|
command += "{args} sample.rs > output/{name}.snapshot.txt".format(
|
||||||
arguments
|
name=name,
|
||||||
|
args=arguments
|
||||||
)
|
)
|
||||||
print("generating snapshot for {}".format(name))
|
print("generating snapshot for {}".format(name))
|
||||||
subprocess.call(command, shell=True)
|
subprocess.call(command, shell=True)
|
||||||
|
|
||||||
|
|
||||||
def build_bat():
|
def build_bat():
|
||||||
print("building bat")
|
print("building bat")
|
||||||
subprocess.call("cargo build", cwd="../..", shell=True)
|
subprocess.call("cargo build", cwd="../..", shell=True)
|
||||||
|
|
||||||
|
|
||||||
def prepare_output_dir():
|
def prepare_output_dir():
|
||||||
shutil.rmtree("output", ignore_errors=True)
|
shutil.rmtree("output", ignore_errors=True)
|
||||||
pathlib.Path("output").mkdir()
|
pathlib.Path("output").mkdir()
|
||||||
|
|
||||||
|
|
||||||
def modify_sample_file():
|
def modify_sample_file():
|
||||||
print("modifying sample.rs to show changes")
|
print("modifying sample.rs to show changes")
|
||||||
shutil.copyfile("sample.modified.rs", "sample.rs")
|
shutil.copyfile("sample.modified.rs", "sample.rs")
|
||||||
|
|
||||||
|
|
||||||
def undo_sample_file_modification():
|
def undo_sample_file_modification():
|
||||||
print("undoing sample.rs modifications")
|
print("undoing sample.rs modifications")
|
||||||
subprocess.call("git checkout -- sample.rs", shell=True)
|
subprocess.call("git checkout -- sample.rs", shell=True)
|
||||||
|
|
||||||
|
|
||||||
build_bat()
|
build_bat()
|
||||||
prepare_output_dir()
|
prepare_output_dir()
|
||||||
modify_sample_file()
|
modify_sample_file()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user