Skip to content

Commit 3d8ff93

Browse files
authored
Merge pull request #9 from alfiankan/dev
add shell executor config
2 parents 8feaaf4 + 804ee9a commit 3d8ff93

5 files changed

Lines changed: 8 additions & 5 deletions

File tree

cmd/main.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@ func main() {
1919
// reconfigure
2020
fmt.Println("Fresh Configuring, Please Wait ...")
2121
homePath := fmt.Sprintf("%s/.teleterm", os.Getenv("HOME"))
22-
os.Mkdir(homePath, os.ModePerm)
22+
err := os.RemoveAll(homePath)
23+
err = os.Mkdir(homePath, os.ModePerm)
2324

2425
execCmd := new(executor.CommandOutputWriter)
25-
_, outErr, err := execCmd.ExecFullOutput(fmt.Sprintf("cp -r /Users/alfiankan/Development/teleterm/empty/* %s", homePath))
26+
_, outErr, err := execCmd.ExecFullOutput(fmt.Sprintf("wget https://github.com/alfiankan/teleterm/raw/main/empty/teleterm.db -P %s", homePath))
27+
_, outErr, err = execCmd.ExecFullOutput(fmt.Sprintf("wget https://github.com/alfiankan/teleterm/raw/main/empty/config.yaml -P %s", homePath))
2628
if err != nil {
2729
fmt.Println(outErr)
2830
panic(err)

config.yaml

Lines changed: 0 additions & 2 deletions
This file was deleted.

empty/config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
teleterm:
22
telegram_token: "xxxxxxxxx"
3+
shell_executor: "/bin/bash"

executor/command.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ package executor
33
import (
44
"fmt"
55
"os/exec"
6+
7+
"github.com/spf13/viper"
68
)
79

810
type CommandOutputWriter struct{}
911

1012
func (c *CommandOutputWriter) ExecFullOutput(command string) (outOk []byte, outErr []byte, err error) {
1113

12-
cmd := exec.Command("bash", "-c", command)
14+
cmd := exec.Command(viper.GetString("shell_executor"), "-c", command)
1315

1416
out, err := cmd.CombinedOutput()
1517
if err != nil {

teleterm.db

-8 KB
Binary file not shown.

0 commit comments

Comments
 (0)