Skip to content

Commit

Permalink
refactor: move back the main at the root of the package
Browse files Browse the repository at this point in the history
  • Loading branch information
moul committed Dec 27, 2018
1 parent 1ea70a5 commit 70e2bf1
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: install
install:
GO111MODULE=on go build -v -o $(GOPATH)/bin/depviz ./cmd/...
GO111MODULE=on go install -v

.PHONY: test
test:
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ _inspired by this discussion: [jbenet/random-ideas#37](https://github.com/jbenet

```
go get moul.io/depviz
make
````
```

## Usage

Expand Down
2 changes: 1 addition & 1 deletion cmd/chi_util.go → cli/chi_util.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package cli

import (
"net/http"
Expand Down
2 changes: 1 addition & 1 deletion cmd/cmd_airtable.go → cli/cmd_airtable.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package cli

import (
"encoding/json"
Expand Down
2 changes: 1 addition & 1 deletion cmd/cmd_db.go → cli/cmd_db.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package cli

import (
"encoding/json"
Expand Down
2 changes: 1 addition & 1 deletion cmd/cmd_graph.go → cli/cmd_graph.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package cli

import (
"encoding/json"
Expand Down
2 changes: 1 addition & 1 deletion cmd/cmd_pull.go → cli/cmd_pull.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package cli

import (
"encoding/json"
Expand Down
2 changes: 1 addition & 1 deletion cmd/cmd_run.go → cli/cmd_run.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package cli

import (
"encoding/json"
Expand Down
2 changes: 1 addition & 1 deletion cmd/cmd_web.go → cli/cmd_web.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package cli

import (
"bytes"
Expand Down
15 changes: 2 additions & 13 deletions cmd/main.go → cli/root.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package main
package cli // import "moul.io/depviz/cli"

import (
"fmt"
"io/ioutil"
"log"
"os"
"strings"

"github.com/jinzhu/gorm"
_ "github.com/mattn/go-sqlite3"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
Expand All @@ -19,15 +17,6 @@ import (
"moul.io/zapgorm"
)

func main() {
defer zap.L().Sync()
rootCmd := newRootCommand()
if err := rootCmd.Execute(); err != nil {
_, _ = fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(1)
}
}

var (
verbose bool
cfgFile string
Expand All @@ -47,7 +36,7 @@ type DepvizCommand interface {
ParseFlags(*pflag.FlagSet)
}

func newRootCommand() *cobra.Command {
func NewRootCommand() *cobra.Command {
rootCmd := &cobra.Command{
Use: "depviz",
}
Expand Down
19 changes: 19 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package main // import "moul.io/depviz"

import (
"fmt"
"os"

_ "github.com/mattn/go-sqlite3"
"go.uber.org/zap"
"moul.io/depviz/cli"
)

func main() {
defer zap.L().Sync()
rootCmd := cli.NewRootCommand()
if err := rootCmd.Execute(); err != nil {
_, _ = fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(1)
}
}

0 comments on commit 70e2bf1

Please sign in to comment.