diff --git a/cmd/cli/main.go b/cmd/cli/main.go index 9b77b2f..3f403d3 100644 --- a/cmd/cli/main.go +++ b/cmd/cli/main.go @@ -11,10 +11,11 @@ import ( _ "errors" "fmt" _ "gopkg.in/yaml.v3" - "decl/internal/resource" - "decl/internal/source" - "decl/internal/target" - "decl/internal/codec" + "decl/internal/resource" + "decl/internal/source" + "decl/internal/target" + "decl/internal/codec" + "net/url" ) const ( @@ -138,7 +139,14 @@ func ImportSubCommand(cmd *flag.FlagSet, output io.Writer) (err error) { if *ImportResource != "" { slog.Info("ImportResource", "resource", ImportResource) - if addResourceErr := d.AddResource(*ImportResource); addResourceErr != nil { + resourceUri, uriErr := url.Parse(*ImportResource) + if uriErr != nil { + slog.Error("Failed adding resource", "error", uriErr) + } + if resourceUri.Scheme == "" { + resourceUri.Scheme = "file" + } + if addResourceErr := d.AddResource(resourceUri.String()); addResourceErr != nil { slog.Error("Failed adding resource", "error", addResourceErr) } } diff --git a/internal/resource/document.go b/internal/resource/document.go index 2208291..9deeaad 100644 --- a/internal/resource/document.go +++ b/internal/resource/document.go @@ -125,15 +125,12 @@ func (d *Document) AddResourceDeclaration(resourceType string, resourceDeclarati } func (d *Document) AddResource(uri string) error { - //parsedResourceURI, e := url.Parse(uri) - //if e == nil { decl := NewDeclaration() if e := decl.SetURI(uri); e != nil { return e } d.ResourceDecls = append(d.ResourceDecls, *decl) - //} return nil }