Skip to content

Commit

Permalink
Add additional flags (#293)
Browse files Browse the repository at this point in the history
* Add additional flags

* Add docs for flags for running the application
  • Loading branch information
kuskoman committed Feb 26, 2024
1 parent 29b1d50 commit 8ea1f43
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ The application can be run in two ways:

Additionally [Helm chart](./chart/) is provided for easy deployment to Kubernetes.

### Flags

The application supports the following flags:

- `-config`: Path to the configuration file (default: `config.yml`). Takes precedence over `EXPORTER_CONFIG_LOCATION` environment variable.
- `-help`: Show help message.
- `-version`: Show semantic version.

#### Binary Executable

The binary executable can be downloaded from the [releases page](https://github.com/kuskoman/logstash-exporter/releases).
Expand Down
17 changes: 14 additions & 3 deletions cmd/exporter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,28 @@ import (
)

func main() {
version := flag.Bool("version", false, "prints the version and exits")
versionFlag := flag.Bool("version", false, "prints the version and exits")
helpFlag := flag.Bool("help", false, "prints the help message and exits")
configLocationFlag := flag.String("config", config.ExporterConfigLocation, "location of the exporter config file")

flag.Parse()
if *version {

if *helpFlag {
fmt.Printf("Usage of %s:\n", os.Args[0])
fmt.Println()
fmt.Println("Flags:")
flag.PrintDefaults()
return
}

if *versionFlag {
fmt.Printf("%s\n", config.SemanticVersion)
return
}

warn := godotenv.Load()

exporterConfig, err := config.GetConfig(config.ExporterConfigLocation)
exporterConfig, err := config.GetConfig(*configLocationFlag)
if err != nil {
log.Fatalf("failed to get exporter config: %s", err)
os.Exit(1)
Expand Down

0 comments on commit 8ea1f43

Please sign in to comment.