diff --git a/.gitignore b/.gitignore index 23ec6569..7223105b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ /doc/ /lib/ -/bin/ +/bin/ameba /.shards/ # Libraries don't need dependency lock diff --git a/.travis.yml b/.travis.yml index ffc7b6ac..40ce77c4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1 +1,4 @@ language: crystal +after_script: + - make build + - ./bin/ameba diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..91efc969 --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +CRYSTAL_BIN ?= $(shell which crystal) +PREFIX ?= /usr/local + +build: + $(CRYSTAL_BIN) build --release --no-debug -o bin/ameba src/cli.cr $(CRFLAGS) +clean: + rm -f ./bin/ameba +install: build + mkdir -p $(PREFIX)/bin + cp ./bin/ameba $(PREFIX)/bin diff --git a/bin/.keep b/bin/.keep new file mode 100644 index 00000000..e69de29b diff --git a/shard.yml b/shard.yml index 27e79828..4fb9171f 100644 --- a/shard.yml +++ b/shard.yml @@ -1,9 +1,13 @@ name: ameba version: 0.1.0 +crystal: 0.23.1 +license: MIT authors: - Vitalii Elenhaupt -crystal: 0.23.1 +scripts: + postinstall: make build -license: MIT +executables: + - ameba diff --git a/src/ameba.cr b/src/ameba.cr index 043b4846..610a0360 100644 --- a/src/ameba.cr +++ b/src/ameba.cr @@ -23,6 +23,7 @@ module Ameba reporter.report source end reporter.try &.finish sources + sources end def catch(source : Source) diff --git a/src/cli.cr b/src/cli.cr new file mode 100644 index 00000000..3d3c7816 --- /dev/null +++ b/src/cli.cr @@ -0,0 +1,20 @@ +require "option_parser" +require "./ameba" + +OptionParser.parse(ARGV) do |parser| + parser.banner = "Usage: ameba [options]" + + parser.on("-v", "--version", "Print version") do + puts Ameba::VERSION + exit 0 + end + + parser.on("-h", "--help", "Show this help") do + puts parser + exit 0 + end +end + +sources = Ameba.run +failed = sources.any? { |s| !s.valid? } +exit(-1) if failed