Skip to content

Commit

Permalink
feat(core): initial cmd implementation (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
moul committed Jul 27, 2018
1 parent 97fb8bf commit 109cc2d
Show file tree
Hide file tree
Showing 11 changed files with 86 additions and 6 deletions.
10 changes: 5 additions & 5 deletions .circleci/config.yml
Expand Up @@ -48,11 +48,11 @@ jobs:
command: |
sudo apt-get update
sudo apt-get install libssl1.0-dev
#- run:
# name: install core
# command: |
# cd core
# make install
- run:
name: install core
command: |
cd core
make install
- run:
name: test core
command: |
Expand Down
6 changes: 5 additions & 1 deletion core/Makefile
Expand Up @@ -9,7 +9,11 @@ CGO_CPPFLAGS ?= -I/usr/local/opt/openssl/include
BUILD_ENV ?= CGO_LDFLAGS="$(CGO_LDFLAGS)" CGO_CPPFLAGS="$(CGO_CPPFLAGS)"

.PHONY: all
all: test
all: install

.PHONY: install
install:
go install -v ./cmd/...

.PHONY: test
test: generate
Expand Down
4 changes: 4 additions & 0 deletions core/api/node/version.go
@@ -0,0 +1,4 @@
package node

// Version is the node API version
const Version = uint32(1)
3 changes: 3 additions & 0 deletions core/api/p2p/version.go
@@ -1 +1,4 @@
package p2p

// Version is the p2p API version
const Version = uint32(1)
Empty file removed core/cmd/.gitkeep
Empty file.
13 changes: 13 additions & 0 deletions core/cmd/berty/client.go
@@ -0,0 +1,13 @@
package main

import "github.com/spf13/cobra"

func newClientCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "client",
RunE: func(cmd *cobra.Command, args []string) error {
return nil
},
}
return cmd
}
13 changes: 13 additions & 0 deletions core/cmd/berty/daemon.go
@@ -0,0 +1,13 @@
package main

import "github.com/spf13/cobra"

func newDaemonCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "daemon",
RunE: func(cmd *cobra.Command, args []string) error {
return nil
},
}
return cmd
}
14 changes: 14 additions & 0 deletions core/cmd/berty/main.go
@@ -0,0 +1,14 @@
package main

import (
"fmt"
"os"
)

func main() {
rootCmd := newRootCommand()
if err := rootCmd.Execute(); err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(1)
}
}
23 changes: 23 additions & 0 deletions core/cmd/berty/root.go
@@ -0,0 +1,23 @@
package main

import (
"fmt"

"github.com/berty/berty/core"
"github.com/berty/berty/core/api/node"
"github.com/berty/berty/core/api/p2p"
"github.com/spf13/cobra"
)

func newRootCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "berty",
Version: fmt.Sprintf("%s (p2p=%d, ui=%d)", core.Version, p2p.Version, node.Version),
}
cmd.PersistentFlags().BoolP("help", "h", false, "Print usage")
cmd.AddCommand(
newDaemonCommand(),
newClientCommand(),
)
return cmd
}
2 changes: 2 additions & 0 deletions core/sql/sqlcipher/sqlcipher.go
Expand Up @@ -5,6 +5,8 @@ import (

"github.com/jinzhu/gorm"
"github.com/pkg/errors"

// sqlcipher blank import
_ "github.com/xeodou/go-sqlcipher"
)

Expand Down
4 changes: 4 additions & 0 deletions core/version.go
@@ -0,0 +1,4 @@
package core

// Version is the core semver version
const Version = "1.0.0"

0 comments on commit 109cc2d

Please sign in to comment.