Skip to content
Permalink
Browse files

Fixed config init/edition to be opened with a tool available on user OS

  • Loading branch information...
eko committed Aug 20, 2019
1 parent 0b83f57 commit 23fd98b9faa9c1266fc1b0447e30694edaf68149
Showing with 19 additions and 4 deletions.
  1. +2 −2 cmd/edit.go
  2. +2 −2 cmd/init.go
  3. +15 −0 cmd/main.go
@@ -28,10 +28,10 @@ in the source code repository.`,
files = []string{config.Filepath}
}

command := exec.Command("open", files...)
command := exec.Command(openerCommand, files...)

if err := command.Start(); err != nil {
fmt.Printf("❌ Cannot run the 'open' command to edit config file: %v\n", err)
fmt.Printf("❌ Cannot run the '%s' command to edit config file: %v\n", openerCommand, err)
return
}
},
@@ -23,10 +23,10 @@ in the source code repository.`,
return
}

command := exec.Command("open", config.Filepath)
command := exec.Command(openerCommand, config.Filepath)

if err := command.Start(); err != nil {
fmt.Printf("❌ Cannot run the 'open' command to edit config file: %v\n", err)
fmt.Printf("❌ Cannot run the '%s' command to edit config file: %v\n", openerCommand, err)
return
}
} else {
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
"os/signal"
"runtime"
"syscall"

"github.com/eko/monday/pkg/config"
@@ -30,9 +31,13 @@ var (
forwarderComponent *forwarder.Forwarder
runnerComponent *runner.Runner
watcherComponent *watcher.Watcher

openerCommand string
)

func main() {
initRuntimeEnvironment()

rootCmd := &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
conf, err := config.Load()
@@ -61,6 +66,16 @@ func main() {
}
}

func initRuntimeEnvironment() {
switch runtime.GOOS {
case "darwin":
openerCommand = "open"

default:
openerCommand = "gedit"
}
}

func selectProject(conf *config.Config) string {
prompt := promptui.Select{
Label: "Which project do you want to work on?",

0 comments on commit 23fd98b

Please sign in to comment.
You can’t perform that action at this time.