microsoft/hve-core

Public

mirrored from https://github.com/microsoft/hve-coreAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
docs/transparency-note

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

.github/skills/experimental/powerpoint/scripts/export-svg.sh

74lines · modecode

1#!/usr/bin/env bash
2# Copyright (c) Microsoft Corporation.
3# SPDX-License-Identifier: MIT
4#
5# export-svg.sh
6# Export PowerPoint slides to SVG images.
7
8set -euo pipefail
9
10SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
11SKILL_ROOT="$(dirname "${SCRIPT_DIR}")"
12VENV_DIR="${SKILL_ROOT}/.venv"
13
14SKIP_VENV_SETUP=false
15VERBOSE=false
16
17err() {
18 printf "ERROR: %s\n" "$1" >&2
19 exit 1
20}
21
22usage() {
23 cat <<EOF
24Usage: $(basename "$0") [OPTIONS]
25
26Options:
27 --input <path> Input PPTX file path (required)
28 --output-dir <path> Output directory for SVG files (required)
29 --slides <list> Comma-separated slide numbers (optional)
30 --skip-venv-setup Skip virtual environment setup
31 -v, --verbose Enable verbose output
32 -h, --help Show this help message
33EOF
34 exit 0
35}
36
37get_venv_python_path() {
38 if [[ -f "${VENV_DIR}/Scripts/python.exe" ]]; then
39 echo "${VENV_DIR}/Scripts/python.exe"
40 elif [[ -f "${VENV_DIR}/bin/python" ]]; then
41 echo "${VENV_DIR}/bin/python"
42 else
43 err "Python interpreter not found in venv. Run: uv sync --directory \"${SKILL_ROOT}\""
44 fi
45}
46
47main() {
48 local -a pass_through=()
49
50 while (( $# > 0 )); do
51 case "$1" in
52 --skip-venv-setup) SKIP_VENV_SETUP=true; shift ;;
53 -v|--verbose) VERBOSE=true; shift ;;
54 -h|--help) usage ;;
55 *) pass_through+=("$1"); shift ;;
56 esac
57 done
58
59 if [[ "${SKIP_VENV_SETUP}" == "false" ]]; then
60 if ! command -v uv &>/dev/null; then
61 err "uv is required but was not found on PATH."
62 fi
63 uv sync --directory "${SKILL_ROOT}"
64 fi
65
66 local python
67 python="$(get_venv_python_path)"
68
69 [[ "${VERBOSE:-false}" == "true" ]] && pass_through+=("-v")
70
71 "${python}" "${SCRIPT_DIR}/export_svg.py" "${pass_through[@]}"
72}
73
74main "$@"
75