mirror of https://github.com/perkeep/perkeep.git
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:
parent
16d6bbb065
commit
a6e4f87bc7
|
@ -29,12 +29,14 @@ import (
|
||||||
|
|
||||||
type claimsCmd struct {
|
type claimsCmd struct {
|
||||||
server string
|
server string
|
||||||
|
attr string
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
cmdmain.RegisterCommand("claims", func(flags *flag.FlagSet) cmdmain.CommandRunner {
|
cmdmain.RegisterCommand("claims", func(flags *flag.FlagSet) cmdmain.CommandRunner {
|
||||||
cmd := new(claimsCmd)
|
cmd := new(claimsCmd)
|
||||||
flags.StringVar(&cmd.server, "server", "", "Server to fetch claims from. "+serverFlagHelp)
|
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
|
return cmd
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -44,7 +46,7 @@ func (c *claimsCmd) Describe() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *claimsCmd) Usage() {
|
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 {
|
func (c *claimsCmd) Examples() []string {
|
||||||
|
@ -61,7 +63,8 @@ func (c *claimsCmd) RunCommand(args []string) error {
|
||||||
}
|
}
|
||||||
cl := newClient(c.server)
|
cl := newClient(c.server)
|
||||||
res, err := cl.GetClaims(&search.ClaimsRequest{
|
res, err := cl.GetClaims(&search.ClaimsRequest{
|
||||||
Permanode: br,
|
Permanode: br,
|
||||||
|
AttrFilter: c.attr,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in New Issue