96 lines
1.9 KiB
Go
96 lines
1.9 KiB
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"io/ioutil"
|
|
"os"
|
|
)
|
|
|
|
func main() {
|
|
|
|
jsonFile, err := os.Open("metlTestConfig.json")
|
|
// if we os.Open returns an error then handle it
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
}
|
|
|
|
fmt.Println("Successfully Opened metlTestConfig.json")
|
|
// defer the closing of our jsonFile so that we can parse it later on
|
|
defer jsonFile.Close()
|
|
|
|
// read our opened xmlFile as a byte array.
|
|
byteValue, _ := ioutil.ReadAll(jsonFile)
|
|
|
|
// we initialize our Users array
|
|
var metlConfig MetlConfig
|
|
|
|
// we unmarshal our byteArray which contains our
|
|
// jsonFile's content into 'users' which we defined above
|
|
err = json.Unmarshal(byteValue, &metlConfig)
|
|
if err != nil {
|
|
panic("error unmarshalling JSON into MetlConfig struct")
|
|
}
|
|
|
|
bus, err := NewBus(metlConfig)
|
|
if err != nil {
|
|
fmt.Println(err.Error())
|
|
return
|
|
}
|
|
|
|
err = bus.Start()
|
|
if err != nil {
|
|
fmt.Println(err.Error())
|
|
return
|
|
}
|
|
|
|
//stdInID, _ := uuid.Parse("a64b47b0-8ecb-409e-8fbc-5e2f5b93442b")
|
|
//stdInID, _ := uuid.Parse("a64b47b0-8ecb-409e-8fbc-5e2f5b93442b")
|
|
//
|
|
//testConfig := MetlConfig{
|
|
// ActionConfigs: []interface{}{
|
|
// StdInConfig{
|
|
// ActionConfig: ActionConfig{
|
|
// ActionID: stdInID,
|
|
// Type: StdIn,
|
|
// OutputSchema: &Schema{
|
|
// Columns: []ColumnDefinition{
|
|
// {
|
|
// Name: "id",
|
|
// ID:
|
|
// },
|
|
// },
|
|
// },
|
|
// },
|
|
// HasHeader: true,
|
|
// },
|
|
// ModifyColumnConfig{
|
|
//
|
|
// },
|
|
// StdOutConfig{
|
|
//
|
|
// },
|
|
// },
|
|
//}
|
|
|
|
//fmt.Print("\033[H\033[2J")
|
|
//for i := 0; i < 100; i++ {
|
|
// fmt.Printf("\033[0;0H")
|
|
// fmt.Printf("On %d/100\nfarts %d ", i, i)
|
|
// //if isTerminal() {
|
|
// //}
|
|
// //else {
|
|
// // fmt.Printf("On %d/100 ", i)
|
|
// //}
|
|
// time.Sleep(200 * time.Millisecond)
|
|
//}
|
|
}
|
|
|
|
func isTerminal() bool {
|
|
if fileInfo, _ := os.Stdout.Stat(); (fileInfo.Mode() & os.ModeCharDevice) != 0 {
|
|
return true
|
|
} else {
|
|
return false
|
|
}
|
|
}
|