Implemented an optional parameter (attr) in 'camtool claims' to filter by claim type

For example, to obtain all the versions for a given file use:

   $ camtool claims <permanode> --attr="camliContent"

Change-Id: Ibb267a0f95702faa0e7e763c99f99ee446559aac
This commit is contained in:
Hernan Grecco 2014-03-12 14:28:20 -03:00
parent 16d6bbb065
commit a6e4f87bc7
1 changed files with 5 additions and 2 deletions

View File

@ -29,12 +29,14 @@ import (
type claimsCmd struct {
server string
attr string
}
func init() {
cmdmain.RegisterCommand("claims", func(flags *flag.FlagSet) cmdmain.CommandRunner {
cmd := new(claimsCmd)
flags.StringVar(&cmd.server, "server", "", "Server to fetch claims from. "+serverFlagHelp)
flags.StringVar(&cmd.attr, "attr", "", "Filter claims about a specific attribute. If empty, all claims are returned.")
return cmd
})
}
@ -44,7 +46,7 @@ func (c *claimsCmd) Describe() string {
}
func (c *claimsCmd) Usage() {
fmt.Fprintf(os.Stderr, "Usage: camtool [globalopts] claims [--depth=n] permanodeBlobRef\n")
fmt.Fprintf(os.Stderr, "Usage: camtool [globalopts] claims [--depth=n] [--attr=s] permanodeBlobRef\n")
}
func (c *claimsCmd) Examples() []string {
@ -61,7 +63,8 @@ func (c *claimsCmd) RunCommand(args []string) error {
}
cl := newClient(c.server)
res, err := cl.GetClaims(&search.ClaimsRequest{
Permanode: br,
Permanode: br,
AttrFilter: c.attr,
})
if err != nil {
return err