diff --git a/README.md b/README.md index d8c3e4f..34aba2b 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/stranslate b/stranslate index e62f5dc..caa7608 100755 --- a/stranslate +++ b/stranslate @@ -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"