@@ -21,7 +21,7 @@ const GlobalFlags = "global"
2121
2222type GlobalResult struct {
2323 Count uint
24- RetryCount uint
24+ RetryCount int64
2525 BasePath string
2626 Scheme string
2727 Server string
@@ -47,6 +47,8 @@ type paramsResult struct {
4747 headers http.Header
4848}
4949
50+ // New creates a new ParseResult and initializes the flag set
51+ // with the parameters from the given method and global flags.
5052func New (o * parser.Method , in * common.Input , r * parser.Root ) * ParseResult {
5153 fs := flag .NewFlagSet (o .OperationId , flag .ExitOnError )
5254
@@ -71,6 +73,8 @@ func New(o *parser.Method, in *common.Input, r *parser.Root) *ParseResult {
7173 return & p
7274}
7375
76+ // getParamVal returns the value of the parameter from the input map
77+ // if it exists, otherwise it returns the default value of the parameter.
7478func getParamVal (p * parser.Parameter , i * common.Input ) string {
7579 if i != nil {
7680 if input , ok := (* i )[p .Name ]; ok {
@@ -83,12 +87,13 @@ func getParamVal(p *parser.Parameter, i *common.Input) string {
8387 return p .DefaultStr ()
8488}
8589
90+ // getGlobal initializes the global flags and returns a GlobalResult.
8691func getGlobal (fs * flag.FlagSet , r * parser.Root ) * GlobalResult {
8792 g := GlobalResult {}
8893 fs .StringVar (& g .BasePath , "base_path" , getBasePath (r ), "http base path" )
8994 fs .StringVar (& g .Doc , "doc" , "none" , "Generate docs (none, shell)" )
9095 fs .StringVar (& g .Format , "format" , "" , "json format" )
91- fs .UintVar (& g .RetryCount , "retry_count" , 10 , "Number of retries on failure" )
96+ fs .Int64Var (& g .RetryCount , "retry_count" , 10 , "Number of retries on failure" )
9297 fs .StringVar (& g .Scheme , "scheme" , getScheme (r ), "Scheme" )
9398 fs .StringVar (& g .Server , "server" , getHost (r ), "Server" )
9499 fs .UintVar (& g .Count , "count" , 1 , "Number of times to repeat command" )
@@ -124,6 +129,8 @@ func getScheme(r *parser.Root) string {
124129 }
125130}
126131
132+ // ValidateParams checks that all required parameters have values
133+ // and sets global configuration options based on the parsed values.
127134func (p * ParseResult ) ValidateParams () error {
128135 for _ , v := range p .Method .Parameters {
129136 val , ok := p .Values [v .Name ]
@@ -143,6 +150,8 @@ func (p *ParseResult) ValidateParams() error {
143150 return nil
144151}
145152
153+ // getParamValues processes the parameters and returns a paramsResult
154+ // containing the URL values, path, body, and headers for the HTTP request.
146155func (p * ParseResult ) getParamValues () (* paramsResult , error ) {
147156 result := paramsResult {
148157 urlValues : & url.Values {},
0 commit comments