Improve scripts/bash-completion.sh and the command line arguments a bit.

This commit is contained in:
Username404-59 2021-02-26 12:32:18 +01:00
parent 3ea7d384e0
commit fe8be54005
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
3 changed files with 8 additions and 8 deletions

View File

@ -5,11 +5,11 @@ _ybconAutoComplete() {
COMPREPLY=() COMPREPLY=()
current="${COMP_WORDS[COMP_CWORD]}" current="${COMP_WORDS[COMP_CWORD]}"
previous="${COMP_WORDS[COMP_CWORD-1]}" previous="${COMP_WORDS[COMP_CWORD-1]}"
options="-p --help --printresult" options='--help --printresult -p'
if [[ ${current} == -* ]]; then if [[ "${current}" == -* ]]; then
COMPREPLY=( "$(compgen -W "$options" -- "$current")" ) COMPREPLY=("$(compgen -W "$options" -- "$current")")
return 0 return 0
fi fi
} }
complete -F _ybconAutoComplete ybcon complete -o nospace -F _ybconAutoComplete ybcon

View File

@ -8,9 +8,9 @@ EXENAME=ybcon
defaultBinLocation=/opt/bin/ybcon defaultBinLocation=/opt/bin/ybcon
usage() { usage() {
echo "$EXENAME [-h|--help] [-p|-printresult] file" echo "$EXENAME [-h|--help] [-p|--printresult] file"
echo " -h or --help What you're seeing right now" echo " -h or --help What you're seeing right now"
echo " -p or -printresult Prints the transpilation result to stdout" echo " -p or --printresult Prints the transpilation result to stdout"
} }
args=""; args="";
@ -32,7 +32,7 @@ if [ "$#" != 0 ]; then
echo "Usage:" echo "Usage:"
usage usage
exit 0 ;; exit 0 ;;
-p | -printresult ) -p | --printresult )
newArgs "$it" newArgs "$it"
shift ;; shift ;;
*.ybcon ) *.ybcon )

View File

@ -18,7 +18,7 @@ int main(int argc, char* argv[]) {
for (int i = 0; i < argc; i++) for (int i = 0; i < argc; i++)
{ {
currentArg = ((string) argv[i]); currentArg = ((string) argv[i]);
if ((currentArg == "-printresult") || (currentArg == "-p")) printResult = true; if ((currentArg == "--printresult") || (currentArg == "-p")) printResult = true;
else if (currentArg.starts_with("--target=")) target = '.' + currentArg.erase(0, 9); else if (currentArg.starts_with("--target=")) target = '.' + currentArg.erase(0, 9);
} }
const string parsedString = parseString(make_unique<string>(getFileContent(fileName))); const string parsedString = parseString(make_unique<string>(getFileContent(fileName)));