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}) | ||||
| 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 | ||||
| if (UNIX AND NOT MINGW) | ||||
|  | ||||
| @ -5,7 +5,7 @@ _ybconAutoComplete() { | ||||
|   COMPREPLY=() | ||||
|   current="${COMP_WORDS[COMP_CWORD]}" | ||||
|   previous="${COMP_WORDS[COMP_CWORD-1]}" | ||||
|   options='-h -p --help --printresult' | ||||
|   options='-h -p --help --version --printresult' | ||||
|   if [[ "${current}" == -* ]]; then | ||||
|     COMPREPLY=("$(compgen -W "$options" -- "$current")") | ||||
|     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 | ||||
| 
 | ||||
| usage() { | ||||
|   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" | ||||
|   if [ "$1" = false ]; then echo "Invalid arguments, usage:"; fi | ||||
|   echo "$EXENAME [--version] [-h|--help] [-p|--printresult] file" | ||||
|   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=""; | ||||
| run=false; | ||||
| skipArgsIteration=false; | ||||
| 
 | ||||
| newArgs() { | ||||
|   if [ "$args" = "" ]; then | ||||
| @ -25,26 +30,34 @@ newArgs() { | ||||
| } | ||||
| 
 | ||||
| if [ "$#" != 0 ]; then | ||||
|   for it in "$@" | ||||
|   do | ||||
|     case "$it" in | ||||
|       -h | --help ) | ||||
|         echo "Usage:" | ||||
|         usage | ||||
|         exit 0 ;; | ||||
|       -p | --printresult ) | ||||
|         newArgs "$it" | ||||
|         shift ;; | ||||
|       *.ybcon ) | ||||
|         newArgs "$it" | ||||
|         run=true | ||||
|         break ;; | ||||
|       * ) | ||||
|         usage ;; | ||||
|     esac | ||||
|   done | ||||
|   if [ "$#" = 1 ]; then | ||||
|     if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then | ||||
|       usage true | ||||
|       exit 0; | ||||
|     elif [ "$1" = "--version" ]; then | ||||
|       run=true | ||||
|       args="$1" | ||||
|       skipArgsIteration=false; | ||||
|     fi | ||||
|   fi | ||||
|   if [ $skipArgsIteration = true ]; then | ||||
|     for it in "$@" | ||||
|     do | ||||
|       case "$it" in | ||||
|         -p | --printresult ) | ||||
|           newArgs "$it" | ||||
|           shift ;; | ||||
|         *.ybcon ) | ||||
|           newArgs "$it" | ||||
|           run=true | ||||
|           break ;; | ||||
|         * ) | ||||
|       usage false ;; | ||||
|       esac | ||||
|     done | ||||
|   fi | ||||
| else | ||||
|   usage | ||||
|   usage false | ||||
| fi | ||||
| 
 | ||||
| runIt() { eval "$1" " $args"; } | ||||
|  | ||||
| @ -2,6 +2,10 @@ | ||||
| #include <memory> | ||||
| using namespace std; | ||||
| 
 | ||||
| #ifndef YBCON_VERSION | ||||
| #define YBCON_VERSION "UNKNOWN" | ||||
| #endif | ||||
| 
 | ||||
| extern string getFileContent(const string& file); | ||||
| extern void setOutputFileContent(const string& language, const string& file, const string& content); | ||||
| 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); | ||||
| 
 | ||||
| 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" ; | ||||
|     if (fileName != "none" and fileName.ends_with(".ybcon")) | ||||
|     { | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user