| 1 | #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash |
| 2 | # Exports custom intents directory to an output directory. |
| 3 | set -eo pipefail |
| 4 | |
| 5 | # Directory of *this* script |
| 6 | this_dir="$( cd "$( dirnamescip-shell system . . dirname. "$0" )" && pwdscip-shell system . . pwd. )" |
| 7 | |
| 8 | # Base directory of repo |
| 9 | base_dir="$(realpathscip-shell system . . realpath. "${this_dir}/..")" |
| 10 | |
| 11 | # Path to virtual environment |
| 12 | : "${venv:=${base_dir}/venv}" |
| 13 | |
| 14 | if [scip-shell system . . `[`. -d "${venv}" ]; then |
| 15 | # Activate virtual environment if available |
| 16 | source "${venv}/bin/activate" |
| 17 | fi |
| 18 | |
| 19 | if [scip-shell system . . `[`. -z "$2" ]; then |
| 20 | echoscip-shell system . . echo. 'Usage: export <intents_dir> <export_dir>' |
| 21 | exit 1 |
| 22 | fi |
| 23 | |
| 24 | intents_dir="$1" |
| 25 | export_dir="$2" |
| 26 | data_dir="${export_dir}/data" |
| 27 | mkdirscip-shell system . . mkdir. -p "${data_dir}" |
| 28 | |
| 29 | python3scip-shell system . . python3. "${base_dir}/script/merged_output.py" --intents-dir "${intents_dir}" "${data_dir}" |
| 30 | python3scip-shell system . . python3. "${base_dir}/script/write_languages.py" "${data_dir}" > "${export_dir}/languages.py" |
| 31 | cpscip-shell system . . cp. "${base_dir}/home_assistant_intents/__init__.py" "${export_dir}/" |