Complete scripts/fish-completion.fish, improve scripts/ybcon.sh and add a --version argument.
This commit is contained in:
parent
528d1eb36e
commit
a427010099
|
@ -41,6 +41,7 @@ set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${CMAKE_PROJECT_VERSION}-${TI
|
||||||
|
|
||||||
include_directories(${CMAKE_CURRENT_LIST_DIR})
|
include_directories(${CMAKE_CURRENT_LIST_DIR})
|
||||||
add_executable(ybcon src/main.cpp resources/Yerbacon.rc src/parser/MainParse.cpp src/transpiler/MainTranspile.cpp src/etc/filefuncs.cpp src/etc/lexer.cpp src/headers/lex.hpp)
|
add_executable(ybcon src/main.cpp resources/Yerbacon.rc src/parser/MainParse.cpp src/transpiler/MainTranspile.cpp src/etc/filefuncs.cpp src/etc/lexer.cpp src/headers/lex.hpp)
|
||||||
|
target_compile_definitions(ybcon PRIVATE YBCON_VERSION="${PROJECT_VERSION}")
|
||||||
|
|
||||||
# lpkg = linux package, wpkg = windows package
|
# lpkg = linux package, wpkg = windows package
|
||||||
if (UNIX AND NOT MINGW)
|
if (UNIX AND NOT MINGW)
|
||||||
|
|
|
@ -5,7 +5,7 @@ _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='-h -p --help --printresult'
|
options='-h -p --help --version --printresult'
|
||||||
if [[ "${current}" == -* ]]; then
|
if [[ "${current}" == -* ]]; then
|
||||||
COMPREPLY=("$(compgen -W "$options" -- "$current")")
|
COMPREPLY=("$(compgen -W "$options" -- "$current")")
|
||||||
return 0
|
return 0
|
||||||
|
|
|
@ -1 +1,7 @@
|
||||||
set -l commands --help -p --printresult
|
set -l commands --help -p --printresult
|
||||||
|
|
||||||
|
complete -c ybcon -f
|
||||||
|
complete -c ybcon -s h -l help -d "Print the help screen"
|
||||||
|
complete -c ybcon -l version -d "Print the version"
|
||||||
|
complete -c ybcon -s p -l printresult -d "Enable printing the transpilation result to stdout"
|
||||||
|
complete -c ybcon -a "(__fish_complete_suffix .ybcon)"
|
|
@ -8,13 +8,18 @@ EXENAME=ybcon
|
||||||
defaultBinLocation=/opt/bin/ybcon
|
defaultBinLocation=/opt/bin/ybcon
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "$EXENAME [-h|--help] [-p|--printresult] file"
|
if [ "$1" = false ]; then echo "Invalid arguments, usage:"; fi
|
||||||
echo " -h or --help What you're seeing right now"
|
echo "$EXENAME [--version] [-h|--help] [-p|--printresult] file"
|
||||||
echo " -p or --printresult Prints the transpilation result to stdout"
|
if [ "$1" = true ]; then
|
||||||
|
echo " --version Print the version"
|
||||||
|
echo " -h or --help What you're seeing right now"
|
||||||
|
echo " -p or --printresult Enable printing the transpilation result to stdout"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
args="";
|
args="";
|
||||||
run=false;
|
run=false;
|
||||||
|
skipArgsIteration=false;
|
||||||
|
|
||||||
newArgs() {
|
newArgs() {
|
||||||
if [ "$args" = "" ]; then
|
if [ "$args" = "" ]; then
|
||||||
|
@ -25,26 +30,34 @@ newArgs() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ "$#" != 0 ]; then
|
if [ "$#" != 0 ]; then
|
||||||
for it in "$@"
|
if [ "$#" = 1 ]; then
|
||||||
do
|
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
|
||||||
case "$it" in
|
usage true
|
||||||
-h | --help )
|
exit 0;
|
||||||
echo "Usage:"
|
elif [ "$1" = "--version" ]; then
|
||||||
usage
|
run=true
|
||||||
exit 0 ;;
|
args="$1"
|
||||||
-p | --printresult )
|
skipArgsIteration=false;
|
||||||
newArgs "$it"
|
fi
|
||||||
shift ;;
|
fi
|
||||||
*.ybcon )
|
if [ $skipArgsIteration = true ]; then
|
||||||
newArgs "$it"
|
for it in "$@"
|
||||||
run=true
|
do
|
||||||
break ;;
|
case "$it" in
|
||||||
* )
|
-p | --printresult )
|
||||||
usage ;;
|
newArgs "$it"
|
||||||
esac
|
shift ;;
|
||||||
done
|
*.ybcon )
|
||||||
|
newArgs "$it"
|
||||||
|
run=true
|
||||||
|
break ;;
|
||||||
|
* )
|
||||||
|
usage false ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
usage
|
usage false
|
||||||
fi
|
fi
|
||||||
|
|
||||||
runIt() { eval "$1" " $args"; }
|
runIt() { eval "$1" " $args"; }
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
#ifndef YBCON_VERSION
|
||||||
|
#define YBCON_VERSION "UNKNOWN"
|
||||||
|
#endif
|
||||||
|
|
||||||
extern string getFileContent(const string& file);
|
extern string getFileContent(const string& file);
|
||||||
extern void setOutputFileContent(const string& language, const string& file, const string& content);
|
extern void setOutputFileContent(const string& language, const string& file, const string& content);
|
||||||
extern string parseString(unique_ptr<string> toParse);
|
extern string parseString(unique_ptr<string> toParse);
|
||||||
|
@ -9,6 +13,7 @@ extern string parseString(unique_ptr<string> toParse);
|
||||||
extern string transpile(string toTranspile, string language);
|
extern string transpile(string toTranspile, string language);
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
|
if ((argc == 2) && (((string) argv[1]) == "--version")) { cout << YBCON_VERSION << endl; exit(0); }
|
||||||
string fileName = (argv[argc - 1] != nullptr) ? argv[argc - 1] : "none" ;
|
string fileName = (argv[argc - 1] != nullptr) ? argv[argc - 1] : "none" ;
|
||||||
if (fileName != "none" and fileName.ends_with(".ybcon"))
|
if (fileName != "none" and fileName.ends_with(".ybcon"))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue