Add updates module and fix issues

This commit is contained in:
Daniel
2019-01-24 15:23:02 +01:00
parent bde81d815d
commit 20af9efecc
22 changed files with 953 additions and 96 deletions

1
updates/uptool/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
uptool

23
updates/uptool/root.go Normal file
View File

@@ -0,0 +1,23 @@
package main
import (
"fmt"
"os"
"github.com/spf13/cobra"
)
var rootCmd = &cobra.Command{
Use: "uptool",
Short: "helper tool for the update process",
Run: func(cmd *cobra.Command, args []string) {
cmd.Usage()
},
}
func main() {
if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}

35
updates/uptool/scan.go Normal file
View File

@@ -0,0 +1,35 @@
package main
import (
"encoding/json"
"fmt"
"github.com/Safing/portmaster/updates"
"github.com/spf13/cobra"
)
func init() {
rootCmd.AddCommand(scanCmd)
}
var scanCmd = &cobra.Command{
Use: "scan",
Short: "Scan the current directory and print the result",
RunE: scan,
}
func scan(cmd *cobra.Command, args []string) error {
latest, err := updates.ScanForLatest(".", true)
if err != nil {
return err
}
data, err := json.MarshalIndent(latest, "", " ")
if err != nil {
return err
}
fmt.Println(string(data))
return nil
}