38 lines
827 B
Go
38 lines
827 B
Go
package meta
|
|
|
|
import (
|
|
common "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-lens/internal"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-lens/internal/tuiutil"
|
|
"github.com/spf13/cobra"
|
|
"go.etcd.io/bbolt"
|
|
)
|
|
|
|
var tuiCMD = &cobra.Command{
|
|
Use: "tui",
|
|
Short: "",
|
|
Long: "",
|
|
Run: tuiFunc,
|
|
}
|
|
|
|
func init() {
|
|
common.AddComponentPathFlag(tuiCMD, &vPath)
|
|
}
|
|
|
|
func tuiFunc(cmd *cobra.Command, _ []string) {
|
|
db := openBoltDB(cmd, false)
|
|
defer db.Close()
|
|
|
|
app, err := tuiutil.NewApplication(db)
|
|
common.ExitOnErr(cmd, err)
|
|
|
|
err = app.Run()
|
|
common.ExitOnErr(cmd, err)
|
|
}
|
|
|
|
func openBoltDB(cmd *cobra.Command, writable bool) *bbolt.DB {
|
|
db, err := bbolt.Open(vPath, 0o600, &bbolt.Options{
|
|
ReadOnly: !writable,
|
|
})
|
|
common.ExitOnErr(cmd, common.Errf("couldn't open bbolt database: %w", err))
|
|
return db
|
|
}
|