Skip to content

Commit

Permalink
Print help
Browse files Browse the repository at this point in the history
  • Loading branch information
mcasperson committed Nov 19, 2024
1 parent 4fe4f64 commit fa246d5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions internal/args/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"errors"
"flag"
"fmt"
"github.com/OctopusSolutionsEngineering/OctopusRecommendationEngine/internal/checks/naming"
"github.com/OctopusSolutionsEngineering/OctopusRecommendationEngine/internal/checks/organization"
"github.com/OctopusSolutionsEngineering/OctopusRecommendationEngine/internal/checks/performance"
Expand All @@ -23,6 +24,8 @@ func ParseArgs(args []string) (*config.OctolintConfig, error) {

octolintConfig := config.OctolintConfig{}

flags.BoolVar(&octolintConfig.Help, "help", false, "Print usage")

flags.StringVar(&octolintConfig.Url, "url", "", "The Octopus URL e.g. https://myinstance.octopus.app")
flags.StringVar(&octolintConfig.Space, "space", "", "The Octopus space name or ID")
flags.StringVar(&octolintConfig.ApiKey, "apiKey", "", "The Octopus api key")
Expand Down Expand Up @@ -73,6 +76,13 @@ func ParseArgs(args []string) (*config.OctolintConfig, error) {

err := flags.Parse(args)

if octolintConfig.Help {
fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0])
flags.SetOutput(os.Stdout)
flags.PrintDefaults()
os.Exit(0)
}

if err != nil {
return nil, err
}
Expand Down
1 change: 1 addition & 0 deletions internal/config/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
)

type OctolintConfig struct {
Help bool
Url string
Space string
ApiKey string
Expand Down

0 comments on commit fa246d5

Please sign in to comment.