diff --git a/cmd/jb/install.go b/cmd/jb/install.go index db2c42b..d5a135d 100644 --- a/cmd/jb/install.go +++ b/cmd/jb/install.go @@ -18,7 +18,6 @@ import ( "context" "encoding/json" "io/ioutil" - "net/url" "os" "path/filepath" @@ -28,7 +27,7 @@ import ( "gopkg.in/alecthomas/kingpin.v2" ) -func installCommand(dir, jsonnetHome string, urls ...*url.URL) int { +func installCommand(dir, jsonnetHome string, paths ...string) int { if dir == "" { dir = "." } @@ -45,8 +44,8 @@ func installCommand(dir, jsonnetHome string, urls ...*url.URL) int { return 1 } - if len(urls) > 0 { - for _, url := range urls { + if len(paths) > 0 { + for _, path := range paths { // install package specified in command // $ jsonnetpkg install ksonnet git@github.com:ksonnet/ksonnet-lib // $ jsonnetpkg install grafonnet git@github.com:grafana/grafonnet-lib grafonnet @@ -54,10 +53,9 @@ func installCommand(dir, jsonnetHome string, urls ...*url.URL) int { // // github.com/(slug)/(dir) - urlString := url.String() - newDep := parseDepedency(urlString) + newDep := parseDepedency(path) if newDep == nil { - kingpin.Errorf("ignoring unrecognized url: %s", url) + kingpin.Errorf("ignoring unrecognized path: %s", path) continue } diff --git a/cmd/jb/install_test.go b/cmd/jb/install_test.go index 9de6b69..4ef2918 100644 --- a/cmd/jb/install_test.go +++ b/cmd/jb/install_test.go @@ -18,7 +18,6 @@ package main import ( "io/ioutil" - "net/url" "os" "path/filepath" "testing" @@ -30,7 +29,7 @@ import ( func TestInstallCommand(t *testing.T) { testcases := []struct { Name string - URLs []*url.URL + URLs []string ExpectedCode int ExpectedJsonnetFile []byte ExpectedJsonnetLockFile []byte diff --git a/cmd/jb/main.go b/cmd/jb/main.go index 76e0016..942b409 100644 --- a/cmd/jb/main.go +++ b/cmd/jb/main.go @@ -68,7 +68,7 @@ func Main() int { initCmd := a.Command(initActionName, "Initialize a new empty jsonnetfile") installCmd := a.Command(installActionName, "Install all dependencies or install specific ones") - installCmdURLs := installCmd.Arg("packages", "URLs to package to install").URLList() + installCmdPaths := installCmd.Arg("paths", "paths to packages to install, URLs or file paths").Strings() updateCmd := a.Command(updateActionName, "Update all dependencies.") @@ -88,7 +88,7 @@ func Main() int { case initCmd.FullCommand(): return initCommand(workdir) case installCmd.FullCommand(): - return installCommand(workdir, cfg.JsonnetHome, *installCmdURLs...) + return installCommand(workdir, cfg.JsonnetHome, *installCmdPaths...) case updateCmd.FullCommand(): return updateCommand(cfg.JsonnetHome) default: diff --git a/pkg/packages_test.go b/pkg/packages_test.go index 729ab73..3316c02 100644 --- a/pkg/packages_test.go +++ b/pkg/packages_test.go @@ -20,6 +20,7 @@ import ( "path/filepath" "testing" + "github.com/jsonnet-bundler/jsonnet-bundler/pkg/jsonnetfile" "github.com/jsonnet-bundler/jsonnet-bundler/spec" "github.com/stretchr/testify/assert" ) @@ -110,7 +111,7 @@ func TestLoadJsonnetfile(t *testing.T) { assert.Nil(t, err) }() - tempFile := filepath.Join(tempDir, JsonnetFile) + tempFile := filepath.Join(tempDir, jsonnetfile.File) err = ioutil.WriteFile(tempFile, []byte(`{}`), os.ModePerm) assert.Nil(t, err) @@ -128,7 +129,7 @@ func TestLoadJsonnetfile(t *testing.T) { assert.Nil(t, err) }() - tempFile := filepath.Join(tempDir, JsonnetFile) + tempFile := filepath.Join(tempDir, jsonnetfile.File) err = ioutil.WriteFile(tempFile, []byte(jsonnetfileContent), os.ModePerm) assert.Nil(t, err)