Skip to content

Commit

Permalink
change delivery schema
Browse files Browse the repository at this point in the history
  • Loading branch information
henriqueleite42 committed Sep 1, 2024
1 parent d1e34d4 commit 6e2af54
Show file tree
Hide file tree
Showing 30 changed files with 416 additions and 275 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"proto",
"Protofile",
"Protofiles",
"Rpcs",
"Timestampz",
"Usecase",
"Usecases",
Expand Down
4 changes: 2 additions & 2 deletions cli/cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"os/exec"

"github.com/henriqueleite42/anvil/cli/internal/files"
"github.com/henriqueleite42/anvil/cli/internal/parser_anv"
"github.com/henriqueleite42/anvil/cli/internal/parser"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
Expand All @@ -17,7 +17,7 @@ func addBuildCommand(rootCmd *cobra.Command) {
Use: "build",
Short: "Build the file to check for errors",
Run: func(cmd *cobra.Command, args []string) {
schema, err := parser_anv.ParseAnvToAnvp(schemaFile)
schema, err := parser.ParseAnvToAnvp(schemaFile)
if err != nil {
log.Fatal(err)
}
Expand Down
4 changes: 2 additions & 2 deletions cli/cmd/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"log"

"github.com/henriqueleite42/anvil/cli/internal/files"
"github.com/henriqueleite42/anvil/cli/internal/parser_anv"
"github.com/henriqueleite42/anvil/cli/internal/parser"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
Expand All @@ -14,7 +14,7 @@ func addParseCommand(rootCmd *cobra.Command) {
Use: "parse",
Short: "Parse the file to create the formatted version",
Run: func(cmd *cobra.Command, args []string) {
schema, err := parser_anv.ParseAnvToAnvp(schemaFile)
schema, err := parser.ParseAnvToAnvp(schemaFile)
if err != nil {
log.Fatal(err)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package parser_anv
package parser

import (
"fmt"
Expand Down
33 changes: 33 additions & 0 deletions cli/internal/parser/delivery.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package parser

import (
"fmt"

"github.com/henriqueleite42/anvil/cli/schemas"
)

func (self *anvToAnvpParser) delivery(file map[string]any) error {
path := self.getPath("Delivery")

deliveryAny, ok := file["Delivery"]
if ok {
return nil
}

_, ok = deliveryAny.(map[string]any)
if !ok {
return fmt.Errorf("fail to parse \"%s\" to `map[string]any`", path)
}

// TODO parse delivery

// TODO parse grpc

// TODO parse http

// TODO parse queue

self.schema.Delivery = &schemas.Delivery{}

return nil
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package parser_anv
package parser

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package parser_anv
package parser

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package parser_anv
package parser

import (
"fmt"
Expand Down Expand Up @@ -125,14 +125,14 @@ func (self *anvToAnvpParser) resolveEnum(i *resolveInput) (string, error) {
}

func (self *anvToAnvpParser) enums(file map[string]any) error {
enumsSchema, ok := file["Enums"]
enumsAny, ok := file["Enums"]
if !ok {
return nil
}

fullPath := self.getPath("Enums")

enumsMap, ok := enumsSchema.(map[string]any)
enumsMap, ok := enumsAny.(map[string]any)
if !ok {
return fmt.Errorf("fail to parse \"%s\" to `map[string]any`", fullPath)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package parser_anv
package parser

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package parser_anv
package parser

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package parser_anv
package parser

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package parser_anv
package parser

import (
"github.com/henriqueleite42/anvil/cli/internal/files"
Expand Down Expand Up @@ -81,6 +81,11 @@ func (self *anvToAnvpParser) parse(file map[string]any) error {
return err
}

err = self.delivery(file)
if err != nil {
return err
}

return nil
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package parser_anv
package parser

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package parser_anv
package parser

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package parser_anv
package parser

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package parser_anv
package parser

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package parser_anv
package parser

import (
"errors"
Expand Down
Loading

0 comments on commit 6e2af54

Please sign in to comment.