Compare commits
No commits in common. "3cd24e8a8f08eb2a3c8b121e5da17bfc3bfe1028" and "6bf3e86a79128b72f9a93233c3ba1a6ca272cc14" have entirely different histories.
3cd24e8a8f
...
6bf3e86a79
8
.gitignore
vendored
8
.gitignore
vendored
@ -1,8 +0,0 @@
|
||||
.svn
|
||||
.vscode
|
||||
|
||||
*.app
|
||||
*.dmg
|
||||
.DS_Store
|
||||
|
||||
/target
|
316
Cargo.lock
generated
316
Cargo.lock
generated
@ -1,316 +0,0 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "anstream"
|
||||
version = "0.6.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"anstyle-parse",
|
||||
"anstyle-query",
|
||||
"anstyle-wincon",
|
||||
"colorchoice",
|
||||
"is_terminal_polyfill",
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle"
|
||||
version = "1.0.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9"
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-parse"
|
||||
version = "0.2.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9"
|
||||
dependencies = [
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-query"
|
||||
version = "1.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c"
|
||||
dependencies = [
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-wincon"
|
||||
version = "3.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"once_cell",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967"
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.5.38"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed93b9805f8ba930df42c2590f05453d5ec36cbb85d018868a5b24d31f6ac000"
|
||||
dependencies = [
|
||||
"clap_builder",
|
||||
"clap_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_builder"
|
||||
version = "4.5.38"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "379026ff283facf611b0ea629334361c4211d1b12ee01024eec1591133b04120"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
"clap_lex",
|
||||
"strsim",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_derive"
|
||||
version = "4.5.32"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09176aae279615badda0765c0c0b3f6ed53f4709118af73cf4655d85d1530cd7"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_lex"
|
||||
version = "0.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6"
|
||||
|
||||
[[package]]
|
||||
name = "colorchoice"
|
||||
version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990"
|
||||
|
||||
[[package]]
|
||||
name = "dir-odt-to-pdf"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"which",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719"
|
||||
|
||||
[[package]]
|
||||
name = "env_home"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c7f84e12ccf0a7ddc17a6c41c93326024c42920d7ee630d04950e6926645c0fe"
|
||||
|
||||
[[package]]
|
||||
name = "errno"
|
||||
version = "0.3.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cea14ef9355e3beab063703aa9dab15afd25f0667c341310c1e5274bb1d0da18"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
||||
|
||||
[[package]]
|
||||
name = "is_terminal_polyfill"
|
||||
version = "1.70.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.172"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa"
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.9.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12"
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.21.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.95"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.40"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "1.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c71e83d6afe7ff64890ec6b71d6a69bb8a610ab78ce364b3352876bb4c801266"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"errno",
|
||||
"libc",
|
||||
"linux-raw-sys",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.101"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ce2b7fc941b3a24138a0a7cf8e858bfc6a992e7978a068a5c760deb0ed43caf"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
|
||||
|
||||
[[package]]
|
||||
name = "utf8parse"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
||||
|
||||
[[package]]
|
||||
name = "which"
|
||||
version = "7.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "24d643ce3fd3e5b54854602a080f34fb10ab75e0b813ee32d00ca2b44fa74762"
|
||||
dependencies = [
|
||||
"either",
|
||||
"env_home",
|
||||
"rustix",
|
||||
"winsafe",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.59.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm",
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_i686_gnullvm",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_gnullvm",
|
||||
"windows_x86_64_msvc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
||||
|
||||
[[package]]
|
||||
name = "winsafe"
|
||||
version = "0.0.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d135d17ab770252ad95e9a872d365cf3090e3be864a34ab46f48555993efc904"
|
10
Cargo.toml
10
Cargo.toml
@ -1,10 +0,0 @@
|
||||
[package]
|
||||
name = "dir-odt-to-pdf"
|
||||
version = "0.1.0"
|
||||
description = "Convert source directory with odt files to target path with pdf files"
|
||||
authors = ["Jesús Pérez <jpl@jesusperez.pro>"]
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "4.5.38", features = ["derive"] }
|
||||
which = "7.0.3"
|
252
justfile
252
justfile
@ -1,252 +0,0 @@
|
||||
alias b := build
|
||||
alias ba := buildall
|
||||
alias ball := buildall
|
||||
alias t := test
|
||||
alias d := doc
|
||||
alias e := expand
|
||||
alias f := fmt
|
||||
alias be := benchmark
|
||||
alias rt := runtest
|
||||
alias ru := run
|
||||
alias cl := clean
|
||||
alias mkapp := make-app
|
||||
alias i := install
|
||||
alias p := package
|
||||
alias pkg := package
|
||||
|
||||
APP_NAME := file_name(justfile_directory())
|
||||
APP_PACKAGE := "DirOdtToPdf"
|
||||
APP_PACKAGES_PATH := justfile_directory() + "/packages/"
|
||||
APP_RESOURCES_PATH := justfile_directory() + "/resources/"
|
||||
RUN_APP_PATH:= "RunDirOdtToPdf"
|
||||
|
||||
MACOS_ROOT_PATH := justfile_directory() + "/macos/"
|
||||
MACOS_APP_PATH := "DirOdtToPdf.app"
|
||||
MACOS_APP_ICNS_PATH := justfile_directory() + "/resources/icon/app/macos/AppIcon.icns"
|
||||
SRC_MACOS := file_name(justfile_directory()) + ".scpt"
|
||||
|
||||
RUN_SRC := "run.sh"
|
||||
BIN_APP_PATH := "/usr/local/bin"
|
||||
|
||||
default:
|
||||
@just -l
|
||||
|
||||
build:
|
||||
cargo build
|
||||
|
||||
[linux]
|
||||
buildall:
|
||||
@echo "Build {{BOLD + MAGENTA}}{{APP_NAME}}{{NORMAL}} ... "
|
||||
cargo build --release
|
||||
|
||||
[macos]
|
||||
buildall:
|
||||
@echo "\nBuild {{BOLD + MAGENTA}}{{APP_NAME}}{{NORMAL}} universal for {{BOLD + GREEN}}{{os()}}{{NORMAL}} architectures ... "
|
||||
@echo "\n{{BOLD + MAGENTA + INVERT}}Apple Silicon (arm64){{NORMAL}}"
|
||||
cargo build --target aarch64-apple-darwin --release
|
||||
@echo "\n{{BOLD + MAGENTA + INVERT}}Intel (x86_64){{NORMAL}} "
|
||||
cargo build --target x86_64-apple-darwin --release
|
||||
@if ! test -r target/apple-darwin/release ; then \
|
||||
mkdir -p target/apple-darwin/release; \
|
||||
fi
|
||||
@if type -p lipo > /dev/null; then \
|
||||
lipo -create \
|
||||
-output target/apple-darwin/release/{{APP_NAME}} \
|
||||
target/aarch64-apple-darwin/release/{{APP_NAME}} \
|
||||
target/x86_64-apple-darwin/release/{{APP_NAME}} ; \
|
||||
fi
|
||||
@if test -r target/apple-darwin/release/{{APP_NAME}} ; then \
|
||||
echo "\n{{BOLD + GREEN + INVERT}}target/apple-darwin/release/{{APP_NAME}}{{NORMAL}} created";\
|
||||
fi
|
||||
|
||||
[macos]
|
||||
make-app: buildall
|
||||
@if test -r {{MACOS_ROOT_PATH + SRC_MACOS}} ; then \
|
||||
echo "\n{{BOLD + GREEN + INVERT}}{{MACOS_APP_PATH}}{{NORMAL}}";\
|
||||
echo "creating from {{BOLD + MAGENTA}}{{MACOS_ROOT_PATH + SRC_MACOS}}{{NORMAL}}";\
|
||||
osacompile -o '{{MACOS_ROOT_PATH + MACOS_APP_PATH}}' '{{MACOS_ROOT_PATH + SRC_MACOS}}'; \
|
||||
fi
|
||||
@if test -r {{MACOS_ROOT_PATH + MACOS_APP_PATH}} ; then \
|
||||
echo "\nCreated {{BOLD + GREEN}}{{MACOS_ROOT_PATH + MACOS_APP_PATH}}{{NORMAL}}";\
|
||||
fi
|
||||
@if test -r '{{MACOS_APP_ICNS_PATH}}' && test -r '{{MACOS_ROOT_PATH + MACOS_APP_PATH}}' ; then \
|
||||
cp {{MACOS_APP_ICNS_PATH}} {{MACOS_ROOT_PATH + MACOS_APP_PATH + "/Contents/Resources/applet.icns"}}; \
|
||||
echo "\nCopy {{BOLD + MAGENTA}}{{MACOS_APP_ICNS_PATH}}{{NORMAL}} to {{BOLD + GREEN}}{{MACOS_APP_PATH + "/Contents/Resources/applet.icns"}}{{NORMAL}}";\
|
||||
fi
|
||||
@if test -r '{{MACOS_APP_ICNS_PATH}}' && test -r '{{MACOS_ROOT_PATH + MACOS_APP_PATH}}' ; then \
|
||||
cp {{MACOS_APP_ICNS_PATH}} {{MACOS_ROOT_PATH + MACOS_APP_PATH + "/Contents/Resources/applet.icns"}}; \
|
||||
echo "\nCopy {{BOLD + MAGENTA}}{{MACOS_APP_ICNS_PATH}}{{NORMAL}} to {{BOLD + GREEN}}{{MACOS_APP_PATH + "/Contents/Resources/applet.icns"}}{{NORMAL}}";\
|
||||
fi
|
||||
@cd {{justfile_directory()}} && if test -r target/apple-darwin/release/{{APP_NAME}} ; then \
|
||||
cp {{'target/apple-darwin/release/' + APP_NAME}} {{MACOS_ROOT_PATH + MACOS_APP_PATH + "/Contents/MacOS/" + APP_NAME}}; \
|
||||
echo "\n{{BOLD + GREEN + INVERT}}target/apple-darwin/release/{{APP_NAME}}{{NORMAL}} to Contets/MacOS/{{APP_NAME}}";\
|
||||
fi
|
||||
@cd {{justfile_directory()}} && if test -r {{RUN_SRC}} ; then \
|
||||
cat {{RUN_SRC}} | sed 's,:-\.,:-{{justfile_directory()}},g' |\
|
||||
sed 's,/usr/local/bin,{{BIN_APP_PATH}},g' > {{MACOS_ROOT_PATH + MACOS_APP_PATH + '/Contents/MacOS/run-' + APP_NAME + '.sh'}}; \
|
||||
chmod +x {{MACOS_ROOT_PATH + MACOS_APP_PATH + '/Contents/MacOS/run-' + APP_NAME + '.sh'}}; \
|
||||
echo "\nCopy and fix paths {{BOLD + GREEN + INVERT}}{{RUN_SRC}}{{NORMAL}} to {{BOLD + MAGENTA}}{{'/run-' + APP_NAME + '.sh'}}{{NORMAL}}";\
|
||||
fi
|
||||
|
||||
[linux]
|
||||
make-app: buildall
|
||||
|
||||
[macos]
|
||||
package: make-app
|
||||
@if test -r {{'/Volumes/' + APP_PACKAGE}} ; then \
|
||||
hdiutil detach {{'/Volumes/' + APP_PACKAGE}}; \
|
||||
fi
|
||||
@if test -r {{APP_PACKAGES_PATH + APP_PACKAGE}} ; then \
|
||||
rm -rf {{APP_PACKAGES_PATH + APP_PACKAGE}}; \
|
||||
fi
|
||||
@if ! test -r '{{MACOS_APP_ICNS_PATH}}' || ! test -r '{{MACOS_ROOT_PATH + MACOS_APP_PATH}}' ; then \
|
||||
echo "\nUnable to Create DMG {{BOLD + GREEN}}{{APP_PACKAGE + '.dmg'}}{{NORMAL}} {{BOLD + RED}}{{MACOS_APP_PATH}} or icns not found{{NORMAL}}";\
|
||||
exit 1 ; \
|
||||
fi
|
||||
@mkdir {{APP_PACKAGES_PATH + APP_PACKAGE}};
|
||||
@if test -r '{{MACOS_APP_ICNS_PATH}}' ; then \
|
||||
cp {{MACOS_APP_ICNS_PATH}} {{MACOS_ROOT_PATH + MACOS_APP_PATH + "/Contents/Resources/applet.icns"}}; \
|
||||
fi
|
||||
@# cp "{{APP_RESOURCES_PATH + 'icon/app/macos/AppIcon.icns'}}" {{APP_PACKAGES_PATH + APP_PACKAGE + "/" + APP_PACKAGE + "-volume.icns"}};
|
||||
@if test -r "{{MACOS_ROOT_PATH + 'install.command'}}" ; then \
|
||||
cp {{MACOS_ROOT_PATH + 'install.command'}} {{APP_PACKAGES_PATH + APP_PACKAGE}};\
|
||||
fi
|
||||
@if test -r "{{MACOS_ROOT_PATH + 'README'}}" ; then \
|
||||
cp {{MACOS_ROOT_PATH + 'README'}} {{APP_PACKAGES_PATH + APP_PACKAGE}};\
|
||||
fi
|
||||
@if test -r {{MACOS_ROOT_PATH + MACOS_APP_PATH}} ; then \
|
||||
cp -pr {{MACOS_ROOT_PATH + MACOS_APP_PATH}} {{APP_PACKAGES_PATH + APP_PACKAGE}};\
|
||||
echo "\nCopy {{BOLD + GREEN}}{{MACOS_APP_PATH}}{{NORMAL}} to {{BOLD + MAGENTA}}{{APP_PACKAGE}}{{NORMAL}}";\
|
||||
fi
|
||||
@if test -r {{'/Volumes/' + APP_PACKAGE + '.dmg'}} ; then \
|
||||
hdiutil detach {{'/Volumes/' + APP_PACKAGE + '.dmg'}}; \
|
||||
fi
|
||||
@if test -r {{APP_PACKAGES_PATH + APP_PACKAGE + ".dmg"}} ; then \
|
||||
rm -f {{APP_PACKAGES_PATH + APP_PACKAGE + ".dmg"}}; \
|
||||
fi
|
||||
@#--volicon ".{{APP_RESOURCES_PATH + 'icon/app/macos/AppIcon.icns'}}"
|
||||
@#--volicon "{{APP_PACKAGE + '-volume.icns'}}"
|
||||
@if type -p create-dmg > /dev/null; then \
|
||||
create-dmg \
|
||||
--volname "{{APP_PACKAGE}}" \
|
||||
--background "{{APP_RESOURCES_PATH + 'ins_background.png'}}" \
|
||||
--window-pos 200 120 \
|
||||
--window-size 500 400 \
|
||||
--icon-size 100 \
|
||||
--app-drop-link 300 200 \
|
||||
--icon "{{MACOS_APP_PATH}}" 100 200 \
|
||||
--icon "README" 100 50 \
|
||||
--icon "install.command" 300 50 \
|
||||
--hide-extension "{{MACOS_APP_PATH}}" \
|
||||
--no-internet-enable \
|
||||
--hdiutil-quiet \
|
||||
"{{APP_PACKAGES_PATH + APP_PACKAGE + '.dmg'}}" \
|
||||
"{{APP_PACKAGES_PATH + APP_PACKAGE}}"; \
|
||||
echo "\nCreate DMG image {{BOLD + GREEN}}{{APP_PACKAGE + '.dmg'}}{{NORMAL}} in {{BOLD + MAGENTA}}{{APP_PACKAGES_PATH}}{{NORMAL}}";\
|
||||
else \
|
||||
hdiutil create -volname "{{APP_PACKAGE}}" -srcfolder {{APP_PACKAGES_PATH + APP_PACKAGE}} -ov -format UDZO {{APP_PACKAGES_PATH + APP_PACKAGE + ".dmg"}}; \
|
||||
echo "\nCreate DMG hd {{BOLD + GREEN}}{{APP_PACKAGE + '.dmg'}}{{NORMAL}} in {{BOLD + MAGENTA}}{{APP_PACKAGES_PATH}}{{NORMAL}}";\
|
||||
fi
|
||||
@if test -r {{'/Volumes/' + APP_PACKAGE}} ; then \
|
||||
hdiutil detach {{'/Voulumes/' + APP_PACKAGE}}; \
|
||||
fi
|
||||
@if test -r {{APP_PACKAGES_PATH + APP_PACKAGE}} ; then \
|
||||
rm -rf {{APP_PACKAGES_PATH + APP_PACKAGE}}; \
|
||||
fi
|
||||
|
||||
[linux]
|
||||
package:
|
||||
@if test -r {{APP_PACKAGES_PATH + APP_PACKAGE}} ; then \
|
||||
rm -rf {{APP_PACKAGES_PATH + APP_PACKAGE}}; \
|
||||
fi
|
||||
@mkdir {{APP_PACKAGES_PATH + APP_PACKAGE}};
|
||||
@if test -r {{APP_PACKAGES_PATH + APP_PACKAGE}} ; then \
|
||||
echo "\nPackage {{BOLD + GREEN}}{{APP_PACKAGE}}{{NORMAL}} in {{BOLD + MAGENTA}}{{APP_PACKAGES_PATH}}{{NORMAL}}";\
|
||||
fi
|
||||
|
||||
delete-run:
|
||||
@bash -c 'echo -en "Are you sure you want to delete current script ({{BOLD + GREEN + BIN_APP_PATH}}/run-{{APP_NAME}}.sh{{NORMAL}})? (s/n): " ;\
|
||||
read -r answer;\
|
||||
case $answer in \
|
||||
yes|y|s|si) \
|
||||
rm -rf "{{BIN_APP_PATH}}/run-{{APP_NAME}}.sh"; \
|
||||
echo -e "\nDeleted {{BOLD + GREEN + INVERT}}{{BIN_APP_PATH + '/run-' + APP_NAME + '.sh'}}{{NORMAL}}"; \
|
||||
;; \
|
||||
*) \
|
||||
echo -e "\n{{BOLD + RED + INVERT}}No deleted{{NORMAL}}"; \
|
||||
;; \
|
||||
esac; \
|
||||
'
|
||||
|
||||
[linux]
|
||||
make-run:
|
||||
@if test -r {{BIN_APP_PATH + '/run-' + APP_NAME + '.sh'}} ; then \
|
||||
echo "\n{{BOLD + MAGENTA}}{{BIN_APP_PATH + '/run-' + APP_NAME + '.sh'}}{{NORMAL}} already exists";\
|
||||
just delete-run; \
|
||||
fi
|
||||
|
||||
[macos]
|
||||
make-run:
|
||||
@if test -r {{BIN_APP_PATH + '/run-' + APP_NAME + '.sh'}} ; then \
|
||||
echo "\n{{BOLD + MAGENTA}}{{BIN_APP_PATH + '/run-' + APP_NAME + '.sh'}}{{NORMAL}} already exists";\
|
||||
just delete-run; \
|
||||
fi
|
||||
@if ! test -r {{BIN_APP_PATH + '/run-' + APP_NAME + '.sh'}} ; then \
|
||||
cp {{MACOS_ROOT_PATH + MACOS_APP_PATH + '/Contents/MacOS/run-' + APP_NAME + '.sh'}} {{BIN_APP_PATH}}; \
|
||||
chmod +x {{BIN_APP_PATH + '/run-' + APP_NAME + '.sh'}}; \
|
||||
echo "\nCopy and fix paths {{BOLD + GREEN + INVERT}}{{RUN_SRC}}{{NORMAL}} to {{BOLD + MAGENTA}}{{BIN_APP_PATH + '/run-' + APP_NAME + '.sh'}}{{NORMAL}}";\
|
||||
fi
|
||||
|
||||
[linux]
|
||||
install: make-app
|
||||
@echo "\nInstall {{BOLD + GREEN + INVERT}}{{BIN_APP_PATH}}{{NORMAL}}";
|
||||
@cd {{justfile_directory()}} && if test -r target/{{APP_NAME}} ; then \
|
||||
cp -p target/{{APP_NAME}} {{BIN_APP_PATH}};\
|
||||
echo "\nCopy {{BOLD + GREEN + INVERT}}target/{{APP_NAME}}{{NORMAL}} to {{BOLD + MAGENTA}}{{BIN_APP_PATH}}{{NORMAL}}";\
|
||||
fi
|
||||
|
||||
[macos]
|
||||
install: make-app
|
||||
@echo "\nInstall {{BOLD + GREEN + INVERT}}{{MACOS_APP_PATH}}{{NORMAL}}" >/tmp/i;
|
||||
@cd {{justfile_directory()}} && if test -r target/{{APP_NAME}} ; then \
|
||||
cp -p target/{{APP_NAME}} {{BIN_APP_PATH}};\
|
||||
echo "\nCopy {{BOLD + GREEN + INVERT}}target/{{APP_NAME}}{{NORMAL}} to {{BOLD + MAGENTA}}{{BIN_APP_PATH}}{{NORMAL}}";\
|
||||
fi
|
||||
@if test -r {{"/Applications/" + MACOS_APP_PATH}} ; then \
|
||||
rm -rf {{"/Applications/" + MACOS_APP_PATH}};\
|
||||
echo "\nRemove /Applications/{{MACOS_APP_PATH}}";\
|
||||
fi
|
||||
@if test -r {{MACOS_ROOT_PATH + MACOS_APP_PATH}} ; then \
|
||||
cp -pr {{MACOS_ROOT_PATH + MACOS_APP_PATH}} /Applications;\
|
||||
echo "\nCopy {{BOLD + GREEN}}{{MACOS_ROOT_PATH + MACOS_APP_PATH}}{{NORMAL}} to /Applications";\
|
||||
fi
|
||||
@just make-run
|
||||
|
||||
test:
|
||||
cargo t
|
||||
|
||||
expand:
|
||||
cargo expand
|
||||
|
||||
benchmark:
|
||||
cargo bench
|
||||
|
||||
runtest:
|
||||
@cd {{justfile_directory()}} && if test -d "test/documents" ; then \
|
||||
rm -rf "test/documents"; \
|
||||
fi
|
||||
@cd {{justfile_directory()}} && if test -r {{RUN_SRC}} ; then \
|
||||
./{{RUN_SRC}}; \
|
||||
fi
|
||||
|
||||
run:
|
||||
cargo b -r
|
||||
|
||||
fmt:
|
||||
cargo +nightly fmt
|
||||
|
||||
clean:
|
||||
cargo clean
|
||||
|
||||
doc:
|
||||
cargo doc --open --no-deps
|
151
src/main.rs
151
src/main.rs
@ -1,151 +0,0 @@
|
||||
use clap::Parser;
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::Command;
|
||||
use std::time::UNIX_EPOCH;
|
||||
use std::env;
|
||||
// use std::time::{SystemTime, UNIX_EPOCH};
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(
|
||||
author,
|
||||
version,
|
||||
about = "Convert source directory with odt files to target path with pdf files with changes verification"
|
||||
)]
|
||||
struct Args {
|
||||
#[arg(help = "Source directory with .odt files")]
|
||||
source: PathBuf,
|
||||
|
||||
#[arg(help = "Target directory for PDFs converted files")]
|
||||
dest: PathBuf,
|
||||
}
|
||||
|
||||
fn needs_conversion(odt_path: &Path, pdf_path: &Path) -> bool {
|
||||
if !pdf_path.exists() {
|
||||
return true;
|
||||
}
|
||||
|
||||
let odt_modified = fs::metadata(odt_path)
|
||||
.and_then(|m| m.modified())
|
||||
.unwrap_or(UNIX_EPOCH);
|
||||
|
||||
let pdf_modified = fs::metadata(pdf_path)
|
||||
.and_then(|m| m.modified())
|
||||
.unwrap_or(UNIX_EPOCH);
|
||||
|
||||
odt_modified > pdf_modified
|
||||
}
|
||||
|
||||
fn get_soffice_path() -> Result<String, String> {
|
||||
// First try environment variable if set
|
||||
if let Ok(path) = env::var("LIBREOFFICE_PATH") {
|
||||
if Path::new(&path).exists() {
|
||||
return Ok(path);
|
||||
}
|
||||
}
|
||||
|
||||
// Check common installation paths
|
||||
let paths = if cfg!(target_os = "macos") {
|
||||
vec![
|
||||
"/Applications/LibreOffice.app/Contents/MacOS/soffice",
|
||||
"/Applications/LibreOffice-still.app/Contents/MacOS/soffice",
|
||||
"/Applications/LibreOffice-fresh.app/Contents/MacOS/soffice",
|
||||
]
|
||||
} else {
|
||||
vec![
|
||||
"/usr/bin/soffice",
|
||||
"/usr/local/bin/soffice",
|
||||
"/usr/lib/libreoffice/program/soffice",
|
||||
"soffice", // Try PATH
|
||||
]
|
||||
};
|
||||
|
||||
// Try each path
|
||||
for path in paths {
|
||||
if Path::new(path).exists() || which::which(path).is_ok() {
|
||||
return Ok(path.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
Err("LibreOffice not found. Please install LibreOffice or set LIBREOFFICE_PATH environment variable.".to_string())
|
||||
}
|
||||
|
||||
fn convert_file(odt_path: &Path, dest_dir: &Path) -> Result<(), String> {
|
||||
let soffice_path = get_soffice_path()?;
|
||||
|
||||
// Verify input file exists and is readable
|
||||
if !odt_path.exists() {
|
||||
return Err(format!("Source file does not exist: {}", odt_path.display()));
|
||||
}
|
||||
|
||||
// Verify destination directory exists and is writable
|
||||
if !dest_dir.exists() {
|
||||
return Err(format!("Destination directory does not exist: {}", dest_dir.display()));
|
||||
}
|
||||
|
||||
// Try to get write permissions on destination directory
|
||||
let metadata = fs::metadata(dest_dir)
|
||||
.map_err(|e| format!("Failed to get destination directory metadata: {}", e))?;
|
||||
|
||||
#[cfg(unix)]
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
#[cfg(unix)]
|
||||
if metadata.permissions().mode() & 0o200 == 0 {
|
||||
return Err(format!("Destination directory is not writable: {}", dest_dir.display()));
|
||||
}
|
||||
|
||||
let output = Command::new(&soffice_path)
|
||||
.args(&[
|
||||
"--headless",
|
||||
"--convert-to",
|
||||
"pdf",
|
||||
"--outdir",
|
||||
dest_dir.to_str().ok_or("Invalid destination path")?,
|
||||
odt_path.to_str().ok_or("Invalid source path")?,
|
||||
])
|
||||
.output()
|
||||
.map_err(|e| format!("Failed to execute LibreOffice command: {}", e))?;
|
||||
|
||||
if !output.status.success() {
|
||||
let error_msg = String::from_utf8_lossy(&output.stderr);
|
||||
let stdout_msg = String::from_utf8_lossy(&output.stdout);
|
||||
return Err(format!(
|
||||
"Conversion failed:\nError: {}\nOutput: {}",
|
||||
error_msg,
|
||||
stdout_msg
|
||||
));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let args = Args::parse();
|
||||
|
||||
// Create target directory if not exists
|
||||
if let Err(e) = fs::create_dir_all(&args.dest) {
|
||||
eprintln!("Error create target directory: {}", e);
|
||||
return;
|
||||
}
|
||||
|
||||
// Process .odt files
|
||||
if let Ok(entries) = fs::read_dir(&args.source) {
|
||||
for entry in entries.flatten() {
|
||||
let path = entry.path();
|
||||
if path.extension().map_or(false, |ext| ext == "odt") {
|
||||
let pdf_path = args.dest.join(
|
||||
path.file_stem()
|
||||
.map(|s| s.to_string_lossy() + ".pdf")
|
||||
.unwrap_or_default()
|
||||
.as_ref(),
|
||||
);
|
||||
if needs_conversion(&path, &pdf_path) {
|
||||
match convert_file(&path, &args.dest) {
|
||||
Ok(_) => println!("Converted: {:?}", path.file_name().unwrap_or_default()),
|
||||
Err(e) => eprintln!("Error: {} - {}", path.display(), e),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user