-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsith.go
More file actions
50 lines (41 loc) · 909 Bytes
/
Copy pathsith.go
File metadata and controls
50 lines (41 loc) · 909 Bytes
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
package main
import (
"fmt"
"os"
"github.com/wx13/sith/editor"
"github.com/wx13/sith/version"
)
func main() {
args := os.Args[1:]
// Handle --version flag
if len(args) > 0 && (args[0] == "-v" || args[0] == "--version") {
fmt.Println("sith", version.Get())
return
}
// Check for --resume flag
resume := false
fileArgs := []string{}
for _, arg := range args {
if arg == "-r" || arg == "--resume" {
resume = true
} else {
fileArgs = append(fileArgs, arg)
}
}
e := editor.NewEditor()
defer e.Quit()
// Try to restore session if:
// - --resume flag is set, OR
// - No files specified and a saved session exists
restored := false
if resume || (len(fileArgs) == 0 && e.HasSavedSession()) {
restored = e.TryRestoreSession(resume)
}
if !restored {
// Normal startup with specified files (or empty)
e.OpenFiles(fileArgs)
}
e.Flush()
e.KeepFlushed()
e.Listen()
}