Skip to content

Commit 28202ca

Browse files
committed
🦺 Refactor: add quarto_checks argument
1 parent 129d762 commit 28202ca

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

src/vuegen/__main__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ def main():
1515
dir_path = args.directory
1616
report_type = args.report_type
1717
streamlit_autorun = args.streamlit_autorun
18+
quarto_cheks = args.quarto_checks
1819

1920
# Determine the report name for logger suffix
2021
if config_path:
@@ -38,13 +39,15 @@ def main():
3839
# Initialize logger
3940
logger, logfile = get_logger(f"{logger_suffix}")
4041
logger.info("logfile: %s", logfile)
42+
4143
# Generate the report
4244
_, _ = report_generator.get_report(
4345
report_type=report_type,
4446
logger=logger,
4547
config_path=config_path,
4648
dir_path=dir_path,
4749
streamlit_autorun=streamlit_autorun,
50+
quarto_checks=quarto_cheks,
4851
)
4952

5053
# Print completion message

src/vuegen/quarto_reportview.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,14 @@ class QuartoReportView(r.ReportView):
2020
BASE_DIR = Path("quarto_report")
2121
STATIC_FILES_DIR = BASE_DIR / "static"
2222

23-
def __init__(self, report: r.Report, report_type: r.ReportType):
23+
def __init__(
24+
self,
25+
report: r.Report,
26+
report_type: r.ReportType,
27+
quarto_cheks: bool = False,
28+
):
2429
super().__init__(report=report, report_type=report_type)
30+
self.quarto_cheks = quarto_cheks
2531
self.BUNDLED_EXECUTION = False
2632
self.quarto_path = "quarto"
2733
# self.env_vars = os.environ.copy()
@@ -190,7 +196,7 @@ def run_report(self, output_dir: str = BASE_DIR) -> None:
190196
r.ReportType.PDF,
191197
r.ReportType.DOCX,
192198
r.ReportType.ODT,
193-
]:
199+
] and self.quarto_cheks:
194200
subprocess.run(
195201
[self.quarto_path, "install", "tinytex", "--no-prompt"],
196202
check=True,

src/vuegen/utils.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,13 @@ def get_parser(prog_name: str, others: dict = {}) -> argparse.Namespace:
232232
default=False,
233233
help="Automatically run the Streamlit app after report generation.",
234234
)
235+
parser.add_argument(
236+
"-qt_cheks",
237+
"--quarto_cheks",
238+
action="store_true", # Automatically sets True if the flag is passed
239+
default=False,
240+
help="Check if Quarto is installed and available for report generation.",
241+
)
235242

236243
# Parse arguments
237244
return parser

0 commit comments

Comments
 (0)