Skip to content

Commit

Permalink
Init cli
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandrebodin committed Jul 4, 2018
1 parent eb372e6 commit 3b1fe24
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 17 deletions.
23 changes: 22 additions & 1 deletion Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,12 @@

[[constraint]]
name = "github.com/BurntSushi/toml"
version = "0.3.0"
version = "0.3.0"

[[constraint]]
branch = "master"
name = "github.com/alexandrebodin/go-findup"

[[constraint]]
name = "github.com/alecthomas/kingpin"
version = "2.2.6"
31 changes: 16 additions & 15 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
package main

import (
"fmt"
"log"
"os"
"strconv"
"strings"

"github.com/BurntSushi/toml"
"github.com/alecthomas/kingpin"
"github.com/alexandrebodin/go-findup"
)

var (
version = "development"
start = kingpin.Command("start", "start a tmux instance").Default()
config = start.Arg("config", "Tmux config file").Default(".tmuxctlrc").String()
)

func main() {
var filePath string
var err error
if len(os.Args) > 1 {
filePath = os.Args[1]
}
kingpin.Version(fmt.Sprintf("tmuxct %s", version)).Author("Alexandre BODIN")
kingpin.CommandLine.HelpFlag.Short('h')
kingpin.CommandLine.VersionFlag.Short('v')
kingpin.Parse()

if filePath == "" {
filePath, err = findup.Find(".tmuxctlrc")
if err != nil {
log.Fatal(err)
}
}
fmt.Printf("Start tmux with config file: %v\n", *config)

if strings.Trim(filePath, " ") == "" {
log.Fatal("not file path provided")
filePath, err := findup.Find(*config)
if err != nil {
log.Fatal(err)
}

var conf sessionConfig
Expand Down
3 changes: 3 additions & 0 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ func (sess *session) addWindow(w *window) {
func (sess *session) start() error {
// get term size
width, height, err := getTermSize()
if err != nil {
return err
}

firstWindow := sess.Windows[0]
_, err = Exec("new-session", "-d", "-s", sess.Name, "-c", sess.Dir, "-n", firstWindow.Name, "-x", width, "-y", height)
Expand Down

0 comments on commit 3b1fe24

Please sign in to comment.