diff --git a/updates/uptool/root.go b/updates/uptool/root.go index f05c3a08..15693ea0 100644 --- a/updates/uptool/root.go +++ b/updates/uptool/root.go @@ -16,11 +16,14 @@ var ( var rootCmd = &cobra.Command{ Use: "uptool", Short: "helper tool for the update process", + Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { cmd.Usage() }, PersistentPreRunE: func(cmd *cobra.Command, args []string) error { - absPath, err := filepath.Abs(".") + dir := args[0] + + absPath, err := filepath.Abs(dir) if err != nil { return err } diff --git a/updates/uptool/scan.go b/updates/uptool/scan.go index 47b280c3..3fe0e1b5 100644 --- a/updates/uptool/scan.go +++ b/updates/uptool/scan.go @@ -14,13 +14,13 @@ func init() { var scanCmd = &cobra.Command{ Use: "scan", - Short: "Scan the current directory and print the result", + Short: "Scan the specified directory and print the result", + Args: cobra.ExactArgs(1), RunE: scan, } func scan(cmd *cobra.Command, args []string) error { - - latest, err := updates.ScanForLatest(".", true) + latest, err := updates.ScanForLatest(updatesStorage.Path, true) if err != nil { return err } diff --git a/updates/uptool/update.go b/updates/uptool/update.go index 6e63fd77..3877a82c 100644 --- a/updates/uptool/update.go +++ b/updates/uptool/update.go @@ -3,6 +3,7 @@ package main import ( "encoding/json" "io/ioutil" + "path/filepath" "github.com/safing/portmaster/updates" "github.com/spf13/cobra" @@ -14,13 +15,13 @@ func init() { var updateCmd = &cobra.Command{ Use: "update", - Short: "Update scans the current directory and updates the index and symlink structure", + Short: "Update scans the specified directory and updates the index and symlink structure", + Args: cobra.ExactArgs(1), RunE: update, } func update(cmd *cobra.Command, args []string) error { - - latest, err := updates.ScanForLatest(".", true) + latest, err := updates.ScanForLatest(updatesStorage.Path, true) if err != nil { return err } @@ -30,7 +31,7 @@ func update(cmd *cobra.Command, args []string) error { return err } - err = ioutil.WriteFile("stable.json", data, 0755) + err = ioutil.WriteFile(filepath.Join(updatesStorage.Path, "stable.json"), data, 0755) if err != nil { return err }