From 3a872063daabf159aaed36a38d8467e2d00a1913 Mon Sep 17 00:00:00 2001 From: Ben Limmer Date: Sat, 12 May 2018 08:04:51 -0600 Subject: [PATCH] Expose linting (#69) * Expose linting * Update conditional * Update entrypoint.sh * formatting --- all/entrypoint.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/all/entrypoint.sh b/all/entrypoint.sh index 40404706..30910020 100755 --- a/all/entrypoint.sh +++ b/all/entrypoint.sh @@ -14,11 +14,14 @@ printUsage() { echo " -l LANGUAGE The language to generate (${SUPPORTED_LANGUAGES[@]})" echo " -o DIRECTORY The output directory for generated files. Will be automatically created." echo " -i includes Extra includes" + echo " --lint CHECKS Enable linting protoc-lint (CHECKS are optional - see https://github.com/ckaznocha/protoc-gen-lint#optional-checks)" echo " --with-gateway Generate grpc-gateway files (experimental)." } GEN_GATEWAY=false +LINT=false +LINT_CHECKS="" SUPPORTED_LANGUAGES=("go" "ruby" "csharp" "java" "python" "objc" "gogo" "php" "node") EXTRA_INCLUDES="" OUT_DIR="" @@ -71,6 +74,14 @@ while test $# -gt 0; do GEN_GATEWAY=true shift ;; + --lint) + LINT=true + if [ "$#" -gt 1 ] && [[ $2 != -* ]]; then + LINT_CHECKS=$2 + shift + fi + shift + ;; *) break ;; @@ -159,6 +170,15 @@ plugins=grpc+embedded\ ;; esac +LINT_STRING='' +if [[ $LINT == true ]]; then + if [[ $LINT_CHECKS == '' ]]; then + LINT_STRING="--lint_out=." + else + LINT_STRING="--lint_out=$LINT_CHECKS:." + fi +fi + PROTO_INCLUDE="-I /usr/include/ \ -I /usr/local/include/ \ -I ${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/ \ @@ -175,6 +195,7 @@ fi protoc $PROTO_INCLUDE \ $GEN_STRING \ + $LINT_STRING \ ${PROTO_FILES[@]} # Python also needs __init__.py files in each directory to import.