aboutsummaryrefslogtreecommitdiff
path: root/cmd/bolt/main.go
diff options
context:
space:
mode:
authorBen Johnson <benbjohnson@yahoo.com>2014-04-11 14:31:34 -0600
committerBen Johnson <benbjohnson@yahoo.com>2014-04-11 14:31:34 -0600
commit714436100adf98a5132e6f4ddb3290231ff89dfd (patch)
tree8a9272322aa759b3d911d3698e6ec21cf71e78d7 /cmd/bolt/main.go
parentAdd nested buckets. (diff)
parentMerge pull request #128 from benbjohnson/import-export (diff)
downloaddedo-714436100adf98a5132e6f4ddb3290231ff89dfd.tar.gz
dedo-714436100adf98a5132e6f4ddb3290231ff89dfd.tar.xz
Merge branch 'master' into nested-keys
Conflicts: db_test.go tx_test.go
Diffstat (limited to 'cmd/bolt/main.go')
-rw-r--r--cmd/bolt/main.go30
1 files changed, 29 insertions, 1 deletions
diff --git a/cmd/bolt/main.go b/cmd/bolt/main.go
index bc5fadb..1930e7d 100644
--- a/cmd/bolt/main.go
+++ b/cmd/bolt/main.go
@@ -2,6 +2,7 @@ package main
import (
"bytes"
+ "encoding/json"
"fmt"
"log"
"os"
@@ -9,6 +10,8 @@ import (
"github.com/codegangsta/cli"
)
+var branch, commit string
+
func main() {
log.SetFlags(0)
NewApp().Run(os.Args)
@@ -19,7 +22,7 @@ func NewApp() *cli.App {
app := cli.NewApp()
app.Name = "bolt"
app.Usage = "BoltDB toolkit"
- app.Version = "0.1.0"
+ app.Version = fmt.Sprintf("0.1.0 (%s %s)", branch, commit)
app.Commands = []cli.Command{
{
Name: "get",
@@ -54,6 +57,24 @@ func NewApp() *cli.App {
},
},
{
+ Name: "import",
+ Usage: "Imports from a JSON dump into a database",
+ Flags: []cli.Flag{
+ &cli.StringFlag{Name: "input"},
+ },
+ Action: func(c *cli.Context) {
+ Import(c.Args().Get(0), c.String("input"))
+ },
+ },
+ {
+ Name: "export",
+ Usage: "Exports a database to JSON",
+ Action: func(c *cli.Context) {
+ path := c.Args().Get(0)
+ Export(path)
+ },
+ },
+ {
Name: "pages",
Usage: "Dumps page information for a database",
Action: func(c *cli.Context) {
@@ -142,3 +163,10 @@ func SetTestMode(value bool) {
logger = log.New(os.Stderr, "", 0)
}
}
+
+// rawMessage represents a JSON element in the import/export document.
+type rawMessage struct {
+ Type string `json:"type,omitempty"`
+ Key []byte `json:"key"`
+ Value json.RawMessage `json:"value"`
+}