diff --git a/.travis.yml b/.travis.yml index 234736e..ad07e7b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,7 @@ go: before_install: - go get golang.org/x/lint/golint - go get honnef.co/go/tools/cmd/staticcheck + - go get github.com/campoy/embedmd jobs: include: - script: make all diff --git a/README.md b/README.md index bf63872..03a1340 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![GoDoc](https://img.shields.io/badge/godoc-reference-5272B4.svg?style=for-the-badge)](https://godoc.org/github.com/jessfraz/gmailfilters) [![Github All Releases](https://img.shields.io/github/downloads/jessfraz/gmailfilters/total.svg?style=for-the-badge)](https://github.com/jessfraz/gmailfilters/releases) -A tool to sync Gmail filters from a config file to your account. +A tool to sync Gmail filters from a config file to your account or export existing filters to file. > **NOTE:** This makes it so the single configuration file is the only way to add filters to your account, meaning if you add a filter via the UI and do not @@ -39,9 +39,20 @@ $ go get github.com/jessfraz/gmailfilters ## Usage +[embedmd]:# (gmailfilters-help.txt console) ```console -$ gmailfilters -h -gmailfilters - A tool to sync Gmail filters from a config file to your account. +gmailfilters - A tool to sync Gmail filters from a local filter file to your account or export existing ones. +Examples: + +* Sync filters from filter file: gmailfilters +* Export your existing filters from gmail: gmailfilters --export + +Example Filter file: + +[[filter]] +query = "to:your_activity@noreply.github.com" +archive = true +read = true. Usage: gmailfilters @@ -55,6 +66,7 @@ Flags: Commands: version Show the version information. + ``` ## Example Filter File @@ -152,4 +164,4 @@ archiveUnlessToMe = true enable the API, and create credentials. Follow the instructions - [for step enabling the API here](https://developers.google.com/gmail/api/quickstart/go). \ No newline at end of file + [for step enabling the API here](https://developers.google.com/gmail/api/quickstart/go). diff --git a/basic.mk b/basic.mk index 61567b5..44a8c58 100644 --- a/basic.mk +++ b/basic.mk @@ -54,7 +54,7 @@ static: prebuild ## Builds a static executable. -tags "$(BUILDTAGS) static_build" \ ${GO_LDFLAGS_STATIC} -o $(NAME) . -all: clean build fmt lint test staticcheck vet install ## Runs a clean, build, fmt, lint, test, staticcheck, vet and install. +all: clean build docs fmt lint test staticcheck vet install ## Runs a clean, build, fmt, lint, test, staticcheck, vet and install. .PHONY: fmt fmt: ## Verifies all files have been `gofmt`ed. @@ -182,6 +182,12 @@ clean: ## Cleanup any build binaries or packages. $(RM) $(NAME) $(RM) -r $(BUILDDIR) +.PHONY: docs +docs: build ## Generates docs from flags. + @./gmailfilters -h > gmailfilters-help.txt 2>&1 || true + @embedmd -w *.md + @rm -f gmailfilters-help.txt + .PHONY: help help: @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | sed 's/^[^:]*://g' | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' diff --git a/main.go b/main.go index eb0c0d4..aceb5fd 100644 --- a/main.go +++ b/main.go @@ -34,11 +34,27 @@ var ( export bool ) +const description = `A tool to sync Gmail filters from a local filter file to your account or export existing ones. +Examples: + +* Sync filters from filter file: gmailfilters +* Export your existing filters from gmail: gmailfilters --export + +Example Filter file: + +[[filter]] +query = "to:your_activity@noreply.github.com" +archive = true +read = true + +` + func main() { // Create a new cli program. p := cli.NewProgram() p.Name = "gmailfilters" - p.Description = "A tool to sync Gmail filters from a config file to your account" + p.Description = description + // Set the GitCommit and Version. p.GitCommit = version.GITCOMMIT p.Version = version.VERSION