@@ -73,32 +73,15 @@ func (r *ShakaPackager) BuildAndValidate() ([]string, error) {
7373 args := []string {}
7474 validationErrors := []string {}
7575
76- for i , stream := range r .StreamOptions {
77- streamDescriptor := []string {}
78- for j , opt := range stream .Options {
79- if err := opt .Validate (); err != nil {
80- validationErrors = append (validationErrors , fmt .Sprintf ("stream[%d].option[%d]: %v" , i , j , err ))
81- continue
82- }
83-
84- streamDescriptor = append (streamDescriptor , opt .Parse ())
85- }
86-
87- args = append (args , strings .Join (streamDescriptor , "," ))
88- }
76+ args , argsError := buildStreamDescriptors (r .StreamOptions ... )
77+ flags , flagError := buildFlags (r .Flags )
8978
90- for i , flag := range r .Flags .Flags {
91- if err := flag .Validate (); err != nil {
92- validationErrors = append (validationErrors , fmt .Sprintf ("flag[%d]: %v" , i , err ))
93- continue
94- }
79+ if argsError != nil || flagError != nil {
80+ return nil , fmt .Errorf ("validation errors: %s" , validationErrors )
81+ }
9582
96- args = append (args , flag .Parse ())
97- }
83+ args = append (args , flags )
9884
99- if len (validationErrors ) > 0 {
100- return nil , fmt .Errorf ("validation errors: %s" , validationErrors )
101- }
10285
10386 return args , nil
10487}
0 commit comments