@@ -83,6 +83,7 @@ func init() {
8383 "NewErrorValidationVerificationStateFailure" : text .NewErrorValidationVerificationStateFailure (),
8484 "NewErrorValidationVerificationCodeInvalidOrAlreadyUsed" : text .NewErrorValidationVerificationCodeInvalidOrAlreadyUsed (),
8585 "NewErrorSystemGeneric" : text .NewErrorSystemGeneric ("{reason}" ),
86+ "NewErrorSystemNoAuthenticationMethodsAvailable" : text .NewErrorSystemNoAuthenticationMethodsAvailable (),
8687 "NewValidationErrorGeneric" : text .NewValidationErrorGeneric ("{reason}" ),
8788 "NewValidationErrorRequired" : text .NewValidationErrorRequired ("{property}" ),
8889 "NewErrorValidationMinLength" : text .NewErrorValidationMinLength (5 , 3 ),
@@ -194,6 +195,20 @@ func init() {
194195}
195196
196197func main () {
198+ if os .Args [1 ] == "elements" {
199+ path , err := filepath .Abs (os .Args [2 ])
200+ if err != nil {
201+ _ , _ = fmt .Fprintf (os .Stderr , "Unable to determine absolute path for elements generation: %+v" , err )
202+ os .Exit (1 )
203+ }
204+
205+ if err := generateElements (path ); err != nil {
206+ _ , _ = fmt .Fprintf (os .Stderr , "Unable to generate locales for elements: %+v" , err )
207+ os .Exit (1 )
208+ }
209+ return
210+ }
211+
197212 if err := clidoc .Generate (cmd .NewRootCmd (nil , nil ), []string {filepath .Join (os .Args [2 ], "cli" )}); err != nil {
198213 _ , _ = fmt .Fprintf (os .Stderr , "Unable to generate CLI docs: %+v" , err )
199214 os .Exit (1 )
@@ -382,3 +397,20 @@ func validateAllMessages(path string) error {
382397
383398 return nil
384399}
400+
401+ func generateElements (messageFilePath string ) error {
402+ // If the file at messageFilePath does not exist, create it
403+ f , err := os .OpenFile (messageFilePath , os .O_APPEND | os .O_CREATE | os .O_WRONLY , 0o644 ) // #nosec
404+ if err != nil {
405+ return errors .Wrapf (err , "unable to open or create message file at %s" , messageFilePath )
406+ }
407+ if err := f .Close (); err != nil {
408+ return errors .Wrapf (err , "unable to close message file at %s" , messageFilePath )
409+ }
410+
411+ sortedMessages := sortMessages ()
412+ if err := writeMessagesJson (messageFilePath , sortedMessages ); err != nil {
413+ return errors .Wrapf (err , "unable to write messages json to %s" , messageFilePath )
414+ }
415+ return nil
416+ }
0 commit comments