Skip to content

Commit

Permalink
Update README and reinstate custom usage.For
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbourgon committed Nov 2, 2018
1 parent d7c82f3 commit 88af6fa
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 278 deletions.
9 changes: 0 additions & 9 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
name = "github.com/oklog/run"
version = "1.0.0"

[[constraint]]
name = "github.com/peterbourgon/usage"
version = "1.0.0"

[[constraint]]
name = "github.com/pkg/errors"
version = "0.8.0"
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ USAGE
fastly-exporter [flags]
FLAGS
-debug false log debug information
-debug false Log debug information
-endpoint http://127.0.0.1:8080/metrics Prometheus /metrics endpoint
-namespace ... Prometheus namespace
-service ... Fastly service ID (repeatable)
-subsystem ... Prometheus subsystem
-token ... Fastly API token
-namespace ... Prometheus namespace (optional)
-service ... Specific Fastly service ID (optional, repeatable)
-subsystem ... Prometheus subsystem (optional)
-token ... Fastly API token (required)
VERSION
1.0.0
2.0.0
```

A valid API -token and at least one -service ID are mandatory. Your service ID
is available at the top of your [Fastly dashboard][db]. [See this link][token]
for information on creating API tokens.
A valid Fastly API -token is mandatory. [See this link][token] for information
on creating API tokens. Providing individual -service IDs is optional, and will
Service IDs are available at the top of your [Fastly dashboard][db].

[db]: https://manage.fastly.com/services/all
[token]: https://docs.fastly.com/guides/account-management-and-security/using-api-tokens#creating-api-tokens
[db]: https://manage.fastly.com/services/all
26 changes: 24 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import (
"os"
"os/signal"
"strings"
"text/tabwriter"
"time"

"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/oklog/run"
"github.com/peterbourgon/usage"
"github.com/prometheus/client_golang/prometheus/promhttp"
)

Expand All @@ -31,7 +31,7 @@ func main() {
debug = fs.Bool("debug", false, "Log debug information")
)
fs.Var(&serviceIDs, "service", "Specific Fastly service ID (optional, repeatable)")
fs.Usage = usage.For(fs, "fastly-exporter [flags]")
fs.Usage = usageFor(fs, "fastly-exporter [flags]")
fs.Parse(os.Args[1:])

var logger log.Logger
Expand Down Expand Up @@ -185,3 +185,25 @@ func (ss *stringslice) String() string {
type httpClient interface {
Do(*http.Request) (*http.Response, error)
}

func usageFor(fs *flag.FlagSet, short string) func() {
return func() {
fmt.Fprintf(os.Stderr, "USAGE\n")
fmt.Fprintf(os.Stderr, " %s\n", short)
fmt.Fprintf(os.Stderr, "\n")
fmt.Fprintf(os.Stderr, "FLAGS\n")
w := tabwriter.NewWriter(os.Stderr, 0, 2, 2, ' ', 0)
fs.VisitAll(func(f *flag.Flag) {
def := f.DefValue
if def == "" {
def = "..."
}
fmt.Fprintf(w, "\t-%s %s\t%s\n", f.Name, def, f.Usage)
})
w.Flush()
fmt.Fprintf(os.Stderr, "\n")
fmt.Fprintf(os.Stderr, "VERSION\n")
fmt.Fprintf(os.Stderr, " %s\n", version)
fmt.Fprintf(os.Stderr, "\n")
}
}
12 changes: 0 additions & 12 deletions vendor/github.com/peterbourgon/usage/.gitignore

This file was deleted.

201 changes: 0 additions & 201 deletions vendor/github.com/peterbourgon/usage/LICENSE

This file was deleted.

12 changes: 0 additions & 12 deletions vendor/github.com/peterbourgon/usage/README.md

This file was deleted.

28 changes: 0 additions & 28 deletions vendor/github.com/peterbourgon/usage/usage_for.go

This file was deleted.

0 comments on commit 88af6fa

Please sign in to comment.