diff --git a/README.md b/README.md index 0553bd8..7b9e0dc 100644 --- a/README.md +++ b/README.md @@ -8,24 +8,24 @@ Use instead of git. ``` $ git clone https://github.com/dataf3l/g - + # add this line to your .bashrc which adds the g folder to your PATH for your convenience $ export PATH=$PATH:/home//place/where/you/cloned/g/ - + ``` ### Using npm: ``` $ npm install @dataf3l/g - + # add this line to your .bashrc which adds the g folder to your PATH for your convenience $ export PATH=$PATH:~/node_modules/@dataf3l/g/ - + ``` # Example .bashrc: @@ -65,14 +65,22 @@ it to the repo, if the file has bad syntax, it will not be added to the repo. ## Supported Languages -- Javascript (via node) - Go (via gofmt) +- Go (via gofmt) +- Java (via javac) +- Javascript (via node) +- Json (via python) +- Perl (via perl) +- Php (via php) +- Ruby (via ruby) +- Xml (via python) +- Yaml (via python) Support comes from external linkers, we are merely a "linker curator" package. ## Upcoming -- CSS, HTML, XML, JAVA, C++, and any which the community is interested in, feel free to post an issue here requesting +- CSS, HTML, C++, and any which the community is interested in, feel free to post an issue here requesting your favourite language: (https://github.com/dataf3l/g/issues). ## Contributing diff --git a/g b/g index 7acab2a..511bdf0 100755 --- a/g +++ b/g @@ -9,33 +9,45 @@ # more languages in the future do_add() { - for file in "$PARAMS" + for files in "$PARAMS" do - case $file in - *.js ) + for file in $files + do printf "$(tput setaf 1)" - node --check $file && git $CMD $file + echo $file + case $file in + *.go ) + gofmt -e $file > /dev/null && git $CMD $file;; + *.java ) + javac $file && git $CMD $file;; + *.js ) + node --check $file && git $CMD $file;; + *.json ) + python -c 'import json, sys;json_file = open(sys.argv[1]); json.loads(json_file.read());json_file.close()' $file && git $CMD $file;; + *.perl ) + perl -c $file && git $CMD $file;; + *.php ) + php -l $file && git $CMD $file;; + *.py ) + python -m py_compile $file && git $CMD $file;; + *.rb ) + ruby -c $file && git $CMD $file;; + *.xml ) + python -c "import sys, xml.dom.minidom as d; d.parse(sys.argv[1])" $file && git $CMD $file;; + *.yaml ) + python -c 'msg = "to suppont yaml extension please run:\npip install pyyaml"; exec("try: import yaml, sys\nexcept: print(msg)");print(yaml.safe_load(sys.stdin))' < $file && git $CMD $file;; + * ) + echo "$(tput setaf 3)Warning, file extension ($file) is Unchecked, please add a checker to g (https://github.com/dataf3l/g), with your help, we can have a world where nothing is Unchecked." + git $CMD $file + continue + esac printf "$(tput sgr0)" - ;; - *.go ) - printf "$(tput setaf 1)" - gofmt -e $file > /dev/null && git $CMD $file - printf "$(tput sgr0)" - ;; - *.php ) - printf "$(tput setaf 1)" - php -l $file && git $CMD $file - printf "$(tput sgr0)" - ;; - * ) - echo "$(tput setaf 3)Warning, file extension is Unchecked, please add a checker to g (https://github.com/dataf3l/g), with your help, we can have a world where nothing is Unchecked.$(tput sgr0)" - git $CMD $file - esac + done done } main () { if [ "$CMD" = "add" ]; then - do_add + do_add else git $CMD $PARAMS fi @@ -45,5 +57,3 @@ CMD=$1 shift PARAMS=$@ main - -