-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
60 lines (47 loc) · 1.02 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package main
import (
"flag"
"log"
"os"
"github.com/cliche-niche/CS455/blob"
"github.com/cliche-niche/CS455/cli"
"github.com/cliche-niche/CS455/util"
)
func main() {
// Define command-line flags
location := flag.String("location", ".", "Location to store the blob file")
isFile := true
// Parse command-line arguments
flag.Parse()
info, err := os.Stat(*location)
if err != nil {
panic(err)
}
if info.IsDir() {
isFile = false
}
// Initialize and run the cli application
var cli cli.Cli
if isFile {
// name and blobtype are obtained from location string
name, blobtype, path := util.UnrollLocation(*location)
// Initialize the Blob
var b blob.Blob
err := b.InitBlob(name, blobtype, path)
if err != nil {
log.Fatalf("Failed to initialize the blob: %v", err)
}
cli.InitCli(&b, "", false)
} else {
cli.InitCli(nil, *location, true)
cli.FileChangeModal()
}
cli.AddExitModal()
cli.AddErrorModal()
cli.AppInputCapture()
cli.AddHelp()
err = cli.RunApp()
if err != nil {
panic(err)
}
}