Example #1
0
)

type casCommand struct {
	subcommands.Description
	subcommands.Synopsis
	flag.FlagSet
	Config struct {
		Path    string
		Sharing string
	}
	State struct {
		Store chunks.Store
	}
}

var _ = cli.Service(&casCommand{})

func (c *casCommand) getSharingKey(name string, out *[32]byte) error {
	app, err := server.New(cli.Bazil.Config.DataDir.String())
	if err != nil {
		return err
	}
	defer app.Close()

	view := func(tx *db.Tx) error {
		sharingKey, err := tx.SharingKeys().Get(name)
		if err != nil {
			return err
		}
		sharingKey.Secret(out)
		return nil
Example #2
0
	"github.com/boltdb/bolt"
)

type boltCommand struct {
	subcommands.Description
	subcommands.Synopsis
	flag.FlagSet
	Config struct {
		Path string
	}
	State struct {
		DB *bolt.DB
	}
}

var _ = cli.Service(&boltCommand{})

func (c *boltCommand) Setup() (ok bool) {
	var err error
	path := filepath.Join(cli.Bazil.Config.DataDir.String(), c.Config.Path)
	c.State.DB, err = bolt.Open(path, 0600)
	if err != nil {
		log.Printf("cannot open database: %v", err)
		return false
	}
	return true
}

func (c *boltCommand) Teardown() (ok bool) {
	c.State.DB.Close()
	return true