Skip to content

Commit

Permalink
add getcid tool
Browse files Browse the repository at this point in the history
  • Loading branch information
makew0rld committed Jun 3, 2024
1 parent 77092c6 commit 66adbf5
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
12 changes: 12 additions & 0 deletions getcid/cmd/main.go
Original file line number Diff line number Diff line change
@@ -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:]))
}
25 changes: 25 additions & 0 deletions getcid/getcid.go
Original file line number Diff line number Diff line change
@@ -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
}
6 changes: 6 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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:
Expand Down

0 comments on commit 66adbf5

Please sign in to comment.