Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Command = &cli.Command{ Name: "ls", Aliases: []string{"list"}, Usage: "list one bucket in the database", ArgsUsage: "<database file> [db path]", Flags: []cli.Flag{ &cli.DurationFlag{ Usage: "timeout for opening the database", Name: "open-timeout", Value: 500 * time.Millisecond, EnvVars: []string{"OPEN_TIMEOUT"}, }, }, Action: func(c *cli.Context) error { if c.NArg() < 1 { return fmt.Errorf("db file and path must be provided") } sourceFile := c.Args().Get(0) p := c.Args().Get(1) if p == "" { p = "/" } dbp, err := dbpath.Parse(p) if err != nil { return fmt.Errorf("while parsing path %s: %w", p, err) } db, err := bolted.Open(sourceFile, 0700, bolted.Options{ Options: bbolt.Options{ Timeout: c.Duration("open-timeout"), ReadOnly: true, }, }) if err != nil { return fmt.Errorf("while opening database: %w", err) } return db.Read(func(tx bolted.ReadTx) error { for it := tx.Iterate(dbp); !it.IsDone(); it.Next() { suffix := "" if it.GetValue() == nil { suffix = "/" } fmt.Println(it.GetKey() + suffix) } return nil }) }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.