diff --git a/internal/args/args.go b/internal/args/args.go index a09d8ac..413ed38 100644 --- a/internal/args/args.go +++ b/internal/args/args.go @@ -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" @@ -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") @@ -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 } diff --git a/internal/config/args.go b/internal/config/args.go index 0d6c3e4..25aedd0 100644 --- a/internal/config/args.go +++ b/internal/config/args.go @@ -5,6 +5,7 @@ import ( ) type OctolintConfig struct { + Help bool Url string Space string ApiKey string