Skip to content

Commit

Permalink
start of latex-refactors-2025-01-01-bccxFy 🪄 - kamangir/bolt#746
Browse files Browse the repository at this point in the history
  • Loading branch information
kamangir committed Jan 1, 2025
1 parent 0ec585d commit 011df79
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 72 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ create a copy of [`sample.env`](./abcli/sample.env) as `.env` and fill in the se

[![pylint](https://github.com/kamangir/awesome-bash-cli/actions/workflows/pylint.yml/badge.svg)](https://github.com/kamangir/awesome-bash-cli/actions/workflows/pylint.yml) [![pytest](https://github.com/kamangir/awesome-bash-cli/actions/workflows/pytest.yml/badge.svg)](https://github.com/kamangir/awesome-bash-cli/actions/workflows/pytest.yml) [![bashtest](https://github.com/kamangir/awesome-bash-cli/actions/workflows/bashtest.yml/badge.svg)](https://github.com/kamangir/awesome-bash-cli/actions/workflows/bashtest.yml) [![PyPI version](https://img.shields.io/pypi/v/abcli.svg)](https://pypi.org/project/abcli/) [![PyPI - Downloads](https://img.shields.io/pypi/dd/abcli)](https://pypistats.org/packages/abcli)

built by 🌀 [`blue_options-4.171.1`](https://github.com/kamangir/awesome-bash-cli), based on 🪄 [`abcli-9.434.1`](https://github.com/kamangir/awesome-bash-cli).
built by 🌀 [`blue_options-4.174.1`](https://github.com/kamangir/awesome-bash-cli), based on 🪄 [`abcli-9.435.1`](https://github.com/kamangir/awesome-bash-cli).
75 changes: 6 additions & 69 deletions abcli/.abcli/plugins/latex.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,77 +3,14 @@
function abcli_latex() {
local task=$(abcli_unpack_keyword $1 help)

local options=$2

if [ "$task" == "build" ]; then
local do_dryrun=$(abcli_option_int "$options" dryrun 0)
local do_install=$(abcli_option_int "$options" install 0)
local do_ps=$(abcli_option_int "$options" ps 1)
local do_pdf=$(abcli_option_int "$options" pdf 1)
local bib_file=$(abcli_option "$options" bib)

[[ "$do_install" == 1 ]] &&
abcli_latex install

local full_path=$3
if [[ ! -f "$full_path" ]]; then
abcli_log_error "@latex: $task: $full_path: file not found."
return 1
fi
path=$(dirname "$full_path")
filename=$(basename "$full_path")
filename=${filename%.*}
abcli_log "building $path / $filename.tex..."

pushd $path >/dev/null

rm -v $filename.dvi
rm -v $filename.ps

local round
for round in 1 2 3; do
abcli_log "round $round..."

abcli_eval dryrun=$do_dryrun \
latex \
-interaction=nonstopmode \
$filename.tex
[[ $? -ne 0 ]] && return 1

[[ ! -z "$bib_file" ]] &&
abcli_eval dryrun=$do_dryrun \
bibtex $bib_file
done

#abcli_eval dryrun=$do_dryrun \
# makeindex $filename.idx

[[ "$do_ps" == 1 ]] &&
abcli_eval dryrun=$do_dryrun \
dvips \
-o $filename.ps \
$filename.dvi

[[ "$do_pdf" == 1 ]] &&
abcli_eval dryrun=$do_dryrun \
ps2pdf $filename.ps

popd >/dev/null

local function_name=abcli_latex_$task
if [[ $(type -t $function_name) == "function" ]]; then
$function_name "${@:2}"
return
fi

if [ "$task" == "install" ]; then
if [[ "$abcli_is_mac" == true ]]; then
brew install --cask mactex
eval "$(/usr/libexec/path_helper)"
return
fi

abcli_log_error "@latex: $task: not supported here."
return 1
fi

abcli_log_error "@latex: $task: command not found."
abcli_log_error "-@latex: $task: command not found."
return 1
}

abcli_source_caller_suffix_path /latex
60 changes: 60 additions & 0 deletions abcli/.abcli/plugins/latex/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#! /usr/bin/env bash

function abcli_latex_build() {
local options=$1

local do_dryrun=$(abcli_option_int "$options" dryrun 0)
local do_bibclean$(abcli_option_int "$options" bibclean 0)
local do_install=$(abcli_option_int "$options" install 0)
local do_ps=$(abcli_option_int "$options" ps 1)
local do_pdf=$(abcli_option_int "$options" pdf 1)
local bib_file=$(abcli_option "$options" bib)

[[ "$do_install" == 1 ]] &&
abcli_latex install

local full_path=$2
if [[ ! -f "$full_path" ]]; then
abcli_log_error "@latex: build: $full_path: file not found."
return 1
fi
local path=$(dirname "$full_path")
local filename=$(basename "$full_path")
filename=${filename%.*}
abcli_log "building $path / $filename.tex..."

pushd $path >/dev/null

rm -v $filename.dvi
rm -v $filename.ps

local round
for round in 1 2 3; do
abcli_log "round $round..."

abcli_eval dryrun=$do_dryrun \
latex \
-interaction=nonstopmode \
$filename.tex
[[ $? -ne 0 ]] && return 1

[[ ! -z "$bib_file" ]] &&
abcli_eval dryrun=$do_dryrun \
bibtex $bib_file
done

#abcli_eval dryrun=$do_dryrun \
# makeindex $filename.idx

[[ "$do_ps" == 1 ]] &&
abcli_eval dryrun=$do_dryrun \
dvips \
-o $filename.ps \
$filename.dvi

[[ "$do_pdf" == 1 ]] &&
abcli_eval dryrun=$do_dryrun \
ps2pdf $filename.ps

popd >/dev/null
}
15 changes: 15 additions & 0 deletions abcli/.abcli/plugins/latex/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#! /usr/bin/env bash

function abcli_latex_install() {
if [[ "$abcli_is_mac" == true ]]; then
brew install bibclean

brew install --cask mactex

abcli_log_warning "restart the terminal..."
return
fi

abcli_log_error "@latex: build: not supported here."
return 1
}
2 changes: 1 addition & 1 deletion abcli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

DESCRIPTION = f"{ICON} a language to speak AI."

VERSION = "9.434.1"
VERSION = "9.435.1"

REPO_NAME = "awesome-bash-cli"

Expand Down
2 changes: 1 addition & 1 deletion abcli/help/latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def build_options(mono: bool):
return "".join(
[
"bib=<name>",
xtra(",dryrun,install,~ps,~pdf", mono=mono),
xtra(",bibclean,dryrun,install,~ps,~pdf", mono=mono),
]
)

Expand Down

0 comments on commit 011df79

Please sign in to comment.