Debug CLI for msg to eml conversion (#4643)
<!-- PR description--> --- #### Does this PR need a docs update or release note? - [ ] ✅ Yes, it's included - [ ] 🕐 Yes, but in a later PR - [x] ⛔ 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 - [ ] ⚡ Unit test - [ ] 💚 E2E
This commit is contained in:
parent
140402361a
commit
576b8b6370
51
src/cmd/converter/converter.go
Normal file
51
src/cmd/converter/converter.go
Normal file
@ -0,0 +1,51 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/alcionai/corso/src/internal/converters/eml"
|
||||
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
||||
)
|
||||
|
||||
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":
|
||||
msg, err := api.BytesToMessageable(body)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
out, err = eml.ToEml(context.Background(), msg)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
default:
|
||||
log.Fatal("Unknown target format", to)
|
||||
}
|
||||
default:
|
||||
log.Fatal("Unknown source format", from)
|
||||
}
|
||||
|
||||
fmt.Print(out)
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user