Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/<your-user-name>/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:

Expand Down Expand Up @@ -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
Expand Down
54 changes: 32 additions & 22 deletions g
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -45,5 +57,3 @@ CMD=$1
shift
PARAMS=$@
main