38 lines
869 B
Go
38 lines
869 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
"os"
|
|
|
|
tea "github.com/charmbracelet/bubbletea"
|
|
|
|
"proxyctl/internal/app"
|
|
"proxyctl/internal/profile"
|
|
"proxyctl/internal/tui"
|
|
)
|
|
|
|
func main() {
|
|
if err := run(os.Args[1:], os.Stdin, os.Stdout); err != nil {
|
|
fmt.Fprintln(os.Stderr, "proxyctl:", err)
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|
|
func run(args []string, input io.Reader, output io.Writer) error {
|
|
if len(args) != 0 {
|
|
return fmt.Errorf("this build supports no command-line arguments")
|
|
}
|
|
configuration, err := profile.ResolveConfigurationForCurrentProcess()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
application, err := app.New(profile.NewOwnedFileStoreAt(configuration.Path, configuration.Owner, configuration.TrustedRoot))
|
|
if err != nil {
|
|
return err
|
|
}
|
|
program := tea.NewProgram(tui.NewModel(application), tea.WithInput(input), tea.WithOutput(output))
|
|
_, err = program.Run()
|
|
return err
|
|
}
|