From cfd01ade02924d0e81004f744adc3f18ac77d5a7 Mon Sep 17 00:00:00 2001 From: Gabriel Arakaki Giovanini Date: Sun, 17 Sep 2023 19:14:19 +0200 Subject: feat: Add check rule --- .gitignore | 2 ++ Makefile | 7 +++++++ main.go | 14 +++++++------- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index f331ccd..7712b56 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ bin/ vendor/ + +index.md diff --git a/Makefile b/Makefile index e5bf8e9..6fafba4 100644 --- a/Makefile +++ b/Makefile @@ -20,3 +20,10 @@ install: compress: upx --best --ultra-brute $(OUT) + +check: build + $(OUT) \ + -f example.md \ + -t text \ + -u https://alpine.mirror.wearetriple.com/v3.18/main/x86_64/APKINDEX.tar.gz \ + -o index.txt diff --git a/main.go b/main.go index 3f3f40c..2231f97 100644 --- a/main.go +++ b/main.go @@ -18,8 +18,8 @@ func main() { var ( url = flag.StringP("url", "u", "", "Url to the APKINDEX.tar.gz") output = flag.StringP("output", "o", "index.md", "Output path") - templateType = flag.StringP("template-type", "p", "text", "Template system to be used, options: html, text") - templateFile = flag.StringP("template-file", "t", "text", "Template file to be used") + templateType = flag.StringP("template-type", "t", "text", "Template system to be used, options: html, text") + templateFile = flag.StringP("template-file", "f", "text", "Template file to be used") ) flag.Parse() @@ -40,7 +40,6 @@ func run( output string, templateType string, templateFile string, - ) error { tarStream, err := fechIndex(url) @@ -68,10 +67,11 @@ func run( } } - s := bufio.NewScanner(tr) - - entries := make([]*Entry, 0) - lines := make([]string, 0) + var ( + s = bufio.NewScanner(tr) + entries = make([]*Entry, 0) + lines = make([]string, 0) + ) for s.Scan() { l := s.Text() -- cgit v1.2.3