<!-- PR description--> --- #### Does this PR need a docs update or release note? - [ ] ✅ Yes, it's included - [x] 🕐 Yes, but in a later PR - [ ] ⛔ No #### Type of change <!--- Please check the type of change your PR introduces: ---> - [ ] 🌻 Feature - [ ] 🐛 Bugfix - [ ] 🗺️ Documentation - [x] 🤖 Supportability/Tests - [ ] 💻 CI/Deployment - [ ] 🧹 Tech Debt/Cleanup #### Issue(s) <!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. --> * https://github.com/alcionai/corso/issues/3893 #### Test Plan <!-- How will this be tested prior to merging.--> - [ ] 💪 Manual - [x] ⚡ Unit test - [ ] 💚 E2E
46 lines
687 B
Go
46 lines
687 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
|
|
"github.com/alcionai/corso/src/internal/converters/eml"
|
|
)
|
|
|
|
func main() {
|
|
if len(os.Args) == 1 {
|
|
fmt.Println("Usage: converter <source-format> <target-format> <filename>")
|
|
os.Exit(1)
|
|
}
|
|
|
|
from := os.Args[1]
|
|
to := os.Args[2]
|
|
filename := os.Args[3]
|
|
|
|
body, err := os.ReadFile(filename)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
var out string
|
|
|
|
switch from {
|
|
case "msg":
|
|
switch to {
|
|
case "eml":
|
|
out, err = eml.FromJSON(context.Background(), body)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
default:
|
|
log.Fatal("Unknown target format", to)
|
|
}
|
|
default:
|
|
log.Fatal("Unknown source format", from)
|
|
}
|
|
|
|
fmt.Print(out)
|
|
}
|