Allow passing text input as a non-option argument
This commit is contained in:
parent
bb9a3e4565
commit
18bb7b98a7
|
@ -14,7 +14,11 @@ SimplyTranslate can use both Google Translate and LibreTranslate, without compro
|
|||
|
||||
## Usage
|
||||
|
||||
Basic usage: `stranslate -f "Chinese" -t "English" -i "你好"`
|
||||
Basic usage:
|
||||
|
||||
`stranslate -f "Chinese" -t "English" -i "你好"`
|
||||
|
||||
`stranslate "你好"`
|
||||
|
||||
For detailed information about the usage of the program, see the manual.
|
||||
|
||||
|
|
|
@ -161,7 +161,13 @@ do
|
|||
esac
|
||||
done
|
||||
|
||||
[ -z "${input}" ] && echo "An input is needed. Please use the -i option." && exit 2
|
||||
# Allow passing text to translate without -i
|
||||
if [ -z "${input}" ]; then
|
||||
shift $(($OPTIND-1))
|
||||
input="$1"
|
||||
fi
|
||||
|
||||
[ -z "${input}" ] && echo "stranslate: No input provided" && exit 2
|
||||
[ -z "${from_language}" ] && from_language="Autodetect"
|
||||
[ -z "${to_language}" ] && to_language="English"
|
||||
|
||||
|
|
Loading…
Reference in New Issue