diff --git a/getcid/cmd/main.go b/getcid/cmd/main.go new file mode 100644 index 0000000..a87c5a5 --- /dev/null +++ b/getcid/cmd/main.go @@ -0,0 +1,12 @@ +package main + +import ( + "os" + + "github.com/starlinglab/integrity-v2/getcid" + "github.com/starlinglab/integrity-v2/util" +) + +func main() { + util.Fatal(getcid.Run(os.Args[1:])) +} diff --git a/getcid/getcid.go b/getcid/getcid.go new file mode 100644 index 0000000..25cbbd4 --- /dev/null +++ b/getcid/getcid.go @@ -0,0 +1,25 @@ +package getcid + +import ( + "fmt" + "os" + + "github.com/starlinglab/integrity-v2/util" +) + +func Run(args []string) error { + if len(args) != 1 { + return fmt.Errorf("specify the path to one file") + } + f, err := os.Open(args[0]) + if err != nil { + return err + } + defer f.Close() + cid, err := util.CalculateFileCid(f) + if err != nil { + return err + } + fmt.Println(cid) + return nil +} diff --git a/main.go b/main.go index d313794..47709c3 100644 --- a/main.go +++ b/main.go @@ -8,7 +8,9 @@ import ( "github.com/starlinglab/integrity-v2/attr" "github.com/starlinglab/integrity-v2/dummy" exportproof "github.com/starlinglab/integrity-v2/export-proof" + "github.com/starlinglab/integrity-v2/getcid" injectc2pa "github.com/starlinglab/integrity-v2/inject-c2pa" + "github.com/starlinglab/integrity-v2/register" "github.com/starlinglab/integrity-v2/upload" "github.com/starlinglab/integrity-v2/util" "github.com/starlinglab/integrity-v2/webhook" @@ -33,6 +35,10 @@ func run(cmd string, args []string) (bool, error) { err = webhook.Run(args) case "upload": err = upload.Run(args) + case "register": + err = register.Run(args) + case "getcid": + err = getcid.Run(args) case "-h", "--help", "help": fmt.Println(helpText) default: