diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..8f70268 Binary files /dev/null and b/.DS_Store differ diff --git a/.tmuxctlrc b/.tmuxctlrc new file mode 100644 index 0000000..e69de29 diff --git a/Gopkg.lock b/Gopkg.lock deleted file mode 100644 index 6e8d852..0000000 --- a/Gopkg.lock +++ /dev/null @@ -1,77 +0,0 @@ -# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. - - -[[projects]] - name = "github.com/BurntSushi/toml" - packages = ["."] - revision = "b26d9c308763d68093482582cea63d69be07a0f0" - version = "v0.3.0" - -[[projects]] - name = "github.com/alecthomas/kingpin" - packages = ["."] - revision = "947dcec5ba9c011838740e680966fd7087a71d0d" - version = "v2.2.6" - -[[projects]] - branch = "master" - name = "github.com/alecthomas/template" - packages = [ - ".", - "parse" - ] - revision = "a0175ee3bccc567396460bf5acd36800cb10c49c" - -[[projects]] - branch = "master" - name = "github.com/alecthomas/units" - packages = ["."] - revision = "2efee857e7cfd4f3d0138cc3cbb1b4966962b93a" - -[[projects]] - branch = "master" - name = "github.com/alexandrebodin/go-findup" - packages = ["."] - revision = "59888d10a1b88cca6f370bac45bf153853b96c7a" - -[[projects]] - name = "github.com/davecgh/go-spew" - packages = ["spew"] - revision = "346938d642f2ec3594ed81d874461961cd0faa76" - version = "v1.1.0" - -[[projects]] - branch = "master" - name = "github.com/pkg/browser" - packages = ["."] - revision = "c90ca0c84f15f81c982e32665bffd8d7aac8f097" - -[[projects]] - name = "github.com/pmezard/go-difflib" - packages = ["difflib"] - revision = "792786c7400a136282c1664665ae0a8db921c6c2" - version = "v1.0.0" - -[[projects]] - name = "github.com/stretchr/objx" - packages = ["."] - revision = "477a77ecc69700c7cdeb1fa9e129548e1c1c393c" - version = "v0.1.1" - -[[projects]] - name = "github.com/stretchr/testify" - packages = [ - ".", - "assert", - "http", - "mock" - ] - revision = "f35b8ab0b5a2cef36673838d662e249dd9c94686" - version = "v1.2.2" - -[solve-meta] - analyzer-name = "dep" - analyzer-version = 1 - inputs-digest = "42ed991431e1367128397e4a05a6d11e681b775945cfdbd6eeed1f9d8d3a3a30" - solver-name = "gps-cdcl" - solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml deleted file mode 100644 index 7bd5474..0000000 --- a/Gopkg.toml +++ /dev/null @@ -1,50 +0,0 @@ -# Gopkg.toml example -# -# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md -# for detailed Gopkg.toml documentation. -# -# required = ["github.com/user/thing/cmd/thing"] -# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] -# -# [[constraint]] -# name = "github.com/user/project" -# version = "1.0.0" -# -# [[constraint]] -# name = "github.com/user/project2" -# branch = "dev" -# source = "github.com/myfork/project2" -# -# [[override]] -# name = "github.com/x/y" -# version = "2.4.0" -# -# [prune] -# non-go = false -# go-tests = true -# unused-packages = true - - -[prune] - go-tests = true - unused-packages = true - -[[constraint]] - name = "github.com/BurntSushi/toml" - version = "0.3.0" - -[[constraint]] - branch = "master" - name = "github.com/alexandrebodin/go-findup" - -[[constraint]] - name = "github.com/alecthomas/kingpin" - version = "2.2.6" - -[[constraint]] - branch = "master" - name = "github.com/pkg/browser" - -[[constraint]] - name = "github.com/stretchr/testify" - version = "1.2.2" diff --git a/Makefile b/Makefile index 9597b7a..9595f1d 100644 --- a/Makefile +++ b/Makefile @@ -18,3 +18,13 @@ test.ci: @echo "Running test" @go test -v ./... .PHONY: test.ci + +build: + @echo "Building" + @go build +.PHONY: build + +docs: + @echo "Building docs" + @static-docs --in docs --out build +.PHONY: docs \ No newline at end of file diff --git a/cli/start.go b/cli/start.go index ea8e9b6..ad9c0c6 100644 --- a/cli/start.go +++ b/cli/start.go @@ -18,21 +18,20 @@ func init() { test := start.Flag("test", "Test config file").Short('t').Bool() start.Action(func(ctx *kingpin.ParseContext) error { - fmt.Printf("Start tmux with config file: %v\n", *configPath) filePath, err := findup.Find(*configPath) if err != nil { - log.Fatalf("Error locating config file %v\n", err) + kingpin.FatalUsageContext(ctx, "locating config file: %v", err) } file, err := os.Open(filePath) if err != nil { - log.Fatalf("Error openning config file %v\n", err) + kingpin.FatalUsageContext(ctx, "Error openning config file %v\n", err) } conf, err := config.Parse(file) if err != nil { - log.Fatalf("Error parsing %s: %v\n", file.Name(), err) + kingpin.FatalUsageContext(ctx, "Error parsing %s: %v\n", file.Name(), err) } // stop after parsing in case of test @@ -41,19 +40,21 @@ func init() { os.Exit(0) } + fmt.Printf("Start tmux with config file: %v\n", *configPath) + runningSessions, err := tmux.ListSessions() if err != nil { - log.Fatalf("Error listing running sessions %v\n", err) + kingpin.FatalUsageContext(ctx, "Error listing running sessions %v\n", err) } options, err := tmux.GetOptions() if err != nil { - log.Fatalf("Error getting tmux options %v\n", err) + kingpin.FatalUsageContext(ctx, "Error getting tmux options %v\n", err) } sess := builder.NewSession(conf, options) if _, ok := runningSessions[sess.Name]; ok { - log.Fatalf("Session %s is already running\n", sess.Name) + kingpin.FatalUsageContext(ctx, "Session %s is already running\n", sess.Name) } checkError := func(err error) { diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..787ba38 --- /dev/null +++ b/go.mod @@ -0,0 +1,15 @@ +module github.com/alexandrebodin/tmuxctl + +go 1.15 + +require ( + github.com/BurntSushi/toml v0.3.0 + github.com/alecthomas/kingpin v2.2.6+incompatible + github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc // indirect + github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf // indirect + github.com/alexandrebodin/go-findup v0.0.0-20180620214025-59888d10a1b8 + github.com/davecgh/go-spew v1.1.0 // indirect + github.com/pkg/browser v0.0.0-20170505125900-c90ca0c84f15 + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/stretchr/testify v1.2.2 +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..6bde465 --- /dev/null +++ b/go.sum @@ -0,0 +1,18 @@ +github.com/BurntSushi/toml v0.3.0 h1:e1/Ivsx3Z0FVTV0NSOv/aVgbUWyQuzj7DDnFblkRvsY= +github.com/BurntSushi/toml v0.3.0/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/alecthomas/kingpin v2.2.6+incompatible h1:5svnBTFgJjZvGKyYBtMB0+m5wvrbUHiqye8wRJMlnYI= +github.com/alecthomas/kingpin v2.2.6+incompatible/go.mod h1:59OFYbFVLKQKq+mqrL6Rw5bR0c3ACQaawgXx0QYndlE= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc h1:cAKDfWh5VpdgMhJosfJnn5/FoN2SRZ4p7fJNX58YPaU= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf h1:qet1QNfXsQxTZqLG4oE62mJzwPIB8+Tee4RNCL9ulrY= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alexandrebodin/go-findup v0.0.0-20180620214025-59888d10a1b8 h1:e71cKH3DakMUxuBKDb1v+rWiCfZW+jPGf7jOSFM8VJI= +github.com/alexandrebodin/go-findup v0.0.0-20180620214025-59888d10a1b8/go.mod h1:vUL3dISMHKvXeQYHEJcOjDNQTvOTbIhA024o7/umW1Q= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pkg/browser v0.0.0-20170505125900-c90ca0c84f15 h1:mrI+6Ae64Wjt+uahGe5we/sPS1sXjvfT3YjtawAVgps= +github.com/pkg/browser v0.0.0-20170505125900-c90ca0c84f15/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=