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=()
current="${COMP_WORDS[COMP_CWORD]}"
previous="${COMP_WORDS[COMP_CWORD-1]}"
options="-p --help --printresult"
if [[ ${current} == -* ]]; then
COMPREPLY=( "$(compgen -W "$options" -- "$current")" )
options='--help --printresult -p'
if [[ "${current}" == -* ]]; then
COMPREPLY=("$(compgen -W "$options" -- "$current")")
return 0
fi
}
complete -F _ybconAutoComplete ybcon
complete -o nospace -F _ybconAutoComplete ybcon

View File

@ -8,9 +8,9 @@ EXENAME=ybcon
defaultBinLocation=/opt/bin/ybcon
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 " -p or -printresult Prints the transpilation result to stdout"
echo " -p or --printresult Prints the transpilation result to stdout"
}
args="";
@ -32,7 +32,7 @@ if [ "$#" != 0 ]; then
echo "Usage:"
usage
exit 0 ;;
-p | -printresult )
-p | --printresult )
newArgs "$it"
shift ;;
*.ybcon )

View File

@ -18,7 +18,7 @@ int main(int argc, char* argv[]) {
for (int i = 0; i < argc; 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);
}
const string parsedString = parseString(make_unique<string>(getFileContent(fileName)));