forked from KyleBanks/s3fs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
45 lines (37 loc) · 1.05 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Package main acts as the primary entry-point for the gos3 application.
package main
import (
"bufio"
"os"
"github.com/brozzis/s3fs/client"
"github.com/brozzis/s3fs/handler"
"github.com/brozzis/s3fs/indicator"
"github.com/brozzis/s3fs/listener"
"github.com/brozzis/s3fs/output"
)
func main() {
// Determine the output method to use.
out := output.New(os.Stdout)
// Determine the UI indicator to use.
ui := indicator.NewCommandLine(out)
// Determine the required handler and listener types.
// Note: In the future there may be more than one kind to choose from, especially likely for the listener (ie. http listener?).
var h handler.Handler
var l listener.Listener
h = handler.NewS3(client.New("us-east-1"), ui)
l = listener.NewText(ui, bufio.NewScanner(os.Stdin))
// Infinitely listen for and handle user input.
for {
cmds, ok := l.Listen()
if !ok {
continue
}
// For each command received, handle it.
for _, cmd := range cmds {
if err := h.Handle(cmd.Args, out); err != nil {
out.Write(err.Error() + "\n")
break
}
}
}
}