Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
nxy7 committed Jun 18, 2023
1 parent 5ab1d8c commit 7981d15
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 8 deletions.
29 changes: 26 additions & 3 deletions cmd/init.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
/*
Copyright © 2023 NAME HERE <EMAIL ADDRESS>
*/
package cmd

import (
"fmt"
"optimus/utils"
"os"
"os/exec"

"github.com/spf13/cobra"
"github.com/spf13/viper"
)

// initCmd represents the init command
Expand All @@ -21,7 +23,28 @@ Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("init called")
dirPath := utils.ProjectRoot()
viper.SetConfigType("yaml")
viper.SetConfigName("optimus")
viper.AddConfigPath(dirPath)

err := viper.ReadInConfig()
if err != nil {
println(err)
}
init := viper.GetString("init")
c := exec.Command("bash", "-c", init)
c.Stdout = os.Stdout
err = c.Run()
if err != nil {
println(err)
}

// initByLine := strings.Split(init, "\n")
// for _, line := range initByLine {
// println(line)
// }

},
}

Expand Down
46 changes: 46 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package main

type Config struct {
global Global
init Init
e2e_tests E2eTests
purge Cmd
services []Service
additionalCommands []Cmd
}

type Global struct {
shell_cmd string
}

type Init struct {
cmd string
file string
}

type E2eTests struct {
cmd string
}

type Services struct {
}

type Service struct {
name string
start Cmd
dev Cmd
postDev Cmd
test ServiceTestCmd
dirHash string
}

type Cmd struct {
cmd string
file string
shell string
}

type ServiceTestCmd struct {
cmd Cmd
dependsOn []Service
}
10 changes: 5 additions & 5 deletions optimus.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
config:
shell: bash
global:
shell_cmd: bash -c

start: |
init: |
echo test
x=2
y=3
z=x+y
echo z
export testVar=testVal
e2e_tests: |
${startup}
${cleanup}
services:
frontend:
Expand All @@ -24,5 +24,5 @@ services:
backend/main:
backend/stream_chat:

cleanup: |
purge: |

0 comments on commit 7981d15

Please sign in to comment.