upgpkg: wordpress 6.2.1-1
[ArchLinux/community.git] / languagetool / trunk / languagetool.sh
blobd5003eeb2319e3183c70c75d0d500cc00dbdfd34
1 #!/bin/bash
3 file_present=false
4 asked_for_help=false
5 start_server=false
6 http_server=false
7 force_cli=false
9 declare -a argv=("$@")
11 i=0
12 for arg in "$@"; do
13 if [[ $arg != -* ]]; then
14 file_present=true
16 if [[ $arg == --config* ]]; then
17 start_server=true
19 if [[ $arg == --http ]]; then
20 start_server=true
21 http_server=true
22 unset argv[$i]
24 if [[ $arg == -h ]]; then
25 asked_for_help=true
26 unset argv[$i]
28 if [[ $arg == --help ]]; then
29 asked_for_help=true
30 unset argv[$i]
32 if [[ $arg == --list || $arg == --version ]]; then
33 force_cli=true
35 ((i++))
36 done
38 CP=/usr/share/languagetool
39 for name in /usr/share/java/languagetool/*.jar ; do
40 CP=$CP:$name
41 done
43 CLI_command='org.languagetool.commandline.Main'
44 GUI_command='org.languagetool.gui.Main'
45 NSRV_command='org.languagetool.server.HTTPServer'
46 SSRV_command='org.languagetool.server.HTTPSServer'
48 if $asked_for_help; then
49 echo "Command-line interface (CLI) help:"
50 "$JAVA_HOME/bin/java" -cp $CP $CLI_command -h | sed "s/java -jar languagetool-commandline.jar/languagetool/"
51 echo
52 echo "Graphical user interface (GUI) help:"
53 "$JAVA_HOME/bin/java" -cp $CP $GUI_command -h | sed "s/java org.languagetool.gui.Main/languagetool/"
54 echo
55 echo "HTTP server help:"
56 "$JAVA_HOME/bin/java" -cp $CP $NSRV_command -h | sed "s/HTTPServer/languagetool --http/"
57 echo
58 echo "HTTPS server help:"
59 "$JAVA_HOME/bin/java" -cp $CP $SSRV_command -h | sed "s/HTTPSServer/languagetool/"
60 else
61 if $start_server; then
62 if $http_server; then
63 "$JAVA_HOME/bin/java" -cp $CP $NSRV_command "${argv[@]}"
64 else
65 "$JAVA_HOME/bin/java" -cp $CP $SSRV_command "${argv[@]}"
67 else
68 if ( $file_present || $force_cli ); then
69 "$JAVA_HOME/bin/java" -cp $CP $CLI_command "${argv[@]}"
70 else
71 "$JAVA_HOME/bin/java" -cp $CP $GUI_command "${argv[@]}"