-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommands.go
More file actions
773 lines (693 loc) · 18.8 KB
/
Copy pathcommands.go
File metadata and controls
773 lines (693 loc) · 18.8 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
package main
import (
"fmt"
"io"
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
"unicode/utf8"
tea "github.com/charmbracelet/bubbletea"
)
// --- Message types ---
// DeleteResultMsg is sent when delete operation completes.
type DeleteResultMsg struct {
count int
err error
operations []Operation // operations to push onto undo stack
}
// PasteResultMsg is sent when paste operation completes.
type PasteResultMsg struct {
action string
count int
err error
isCut bool
}
// RenameResultMsg is sent when rename operation completes.
type RenameResultMsg struct {
newName string
err error
op *Operation // operation to push onto undo stack (nil if failed)
}
// DiffMsg carries the diff content for display.
type DiffMsg struct {
diff string
fileName string
}
// ShellExitMsg is sent when the shell process exits.
type ShellExitMsg struct {
err error
}
// OpenFileResultMsg is sent when the file editor exits.
type OpenFileResultMsg struct {
path string
err error
}
// PreviewResultMsg is sent when async preview generation completes.
type PreviewResultMsg struct {
path string
content string
err error
}
// CreateResultMsg is sent when file/directory creation completes.
type CreateResultMsg struct {
name string
err error
}
// --- Undo support ---
// Operation represents a reversible file operation.
type Operation struct {
Type string // "delete" or "rename"
Path string // target path (deleted file or renamed file)
OldPath string // for rename: original path
Backups []string // for delete: backup paths in undoDir (one per file in batch)
Paths []string // for delete batch: original paths corresponding to Backups
}
// undoDir returns the temporary directory for undo backups.
func undoDir() string {
return filepath.Join(os.TempDir(), "traverse-undo")
}
// cleanUndoDir removes the undo directory and all its contents.
func cleanUndoDir() {
os.RemoveAll(undoDir())
}
// ensureUndoDir creates the undo directory if it does not exist.
func ensureUndoDir() error {
return os.MkdirAll(undoDir(), 0755)
}
// --- Helpers ---
// filteredFiles returns files matching the current filter query.
// If no filter is active, returns all files.
func (a *App) filteredFiles() []FileItem {
if a.filterQuery == "" {
return a.files
}
q := strings.ToLower(a.filterQuery)
var result []FileItem
for _, f := range a.files {
if strings.Contains(strings.ToLower(f.Name), q) {
result = append(result, f)
}
}
return result
}
// currentFile returns the file at the cursor position in the filtered view.
func (a *App) currentFile() (FileItem, bool) {
files := a.filteredFiles()
if a.cursor < 0 || a.cursor >= len(files) {
return FileItem{}, false
}
return files[a.cursor], true
}
func (a *App) getSelectedFiles() []string {
files := a.filteredFiles()
if len(a.selected) > 0 {
result := make([]string, 0, len(a.selected))
for idx := range a.selected {
if idx < len(files) {
result = append(result, files[idx].Path)
}
}
return result
}
if len(files) > 0 && a.cursor < len(files) {
return []string{files[a.cursor].Path}
}
return nil
}
func (a *App) gitRepoRelPath(filePath string) string {
if a.gitSvc == nil || !a.gitSvc.IsRepo() {
return ""
}
rel, _ := filepath.Rel(a.gitSvc.Root(), filePath)
return filepath.ToSlash(rel)
}
// --- File operations ---
func (a *App) copyFiles(isCut bool) (tea.Model, tea.Cmd) {
a.clipboardFiles = a.getSelectedFiles()
a.clipboardIsCut = isCut
if len(a.clipboardFiles) == 0 {
return a, nil
}
action := "Copied"
if isCut {
action = "Cut"
}
a.message = fmt.Sprintf("%s %d file(s)", action, len(a.clipboardFiles))
a.messageIsError = false
return a, nil
}
func (a *App) pasteFiles() (tea.Model, tea.Cmd) {
if len(a.clipboardFiles) == 0 {
a.message = "Clipboard is empty"
a.messageIsError = true
return a, nil
}
// Check if any destination files already exist
conflicts := 0
for _, src := range a.clipboardFiles {
dst := filepath.Join(a.cwd, filepath.Base(src))
if _, err := os.Stat(dst); err == nil {
conflicts++
}
}
if conflicts > 0 {
a.confirmAction = "paste-overwrite"
if conflicts == 1 {
a.confirmTarget = filepath.Base(a.clipboardFiles[0])
} else {
a.confirmTarget = fmt.Sprintf("%d conflicting files", conflicts)
}
return a, nil
}
return a.doPaste()
}
func (a *App) doPaste() (tea.Model, tea.Cmd) {
// Capture values for the closure
files := make([]string, len(a.clipboardFiles))
copy(files, a.clipboardFiles)
isCut := a.clipboardIsCut
dstDir := a.cwd
return a, func() tea.Msg {
for _, src := range files {
dst := filepath.Join(dstDir, filepath.Base(src))
// Prevent self-copy
if src == dst {
continue
}
if isCut {
// Move with cross-device fallback
if err := moveFile(src, dst); err != nil {
return PasteResultMsg{err: err}
}
} else {
// Copy
if err := copyFile(src, dst); err != nil {
return PasteResultMsg{err: err}
}
}
}
action := "Pasted"
if isCut {
action = "Moved"
}
return PasteResultMsg{action: action, count: len(files), isCut: isCut}
}
}
func (a *App) deleteFiles() (tea.Model, tea.Cmd) {
files := a.getSelectedFiles()
if len(files) == 0 {
return a, nil
}
if len(files) == 1 {
a.confirmAction = "delete"
a.confirmTarget = filepath.Base(files[0])
} else {
a.confirmAction = "delete"
a.confirmTarget = fmt.Sprintf("%d files", len(files))
}
return a, nil
}
func (a *App) startRename() (tea.Model, tea.Cmd) {
item, ok := a.currentFile()
if !ok {
return a, nil
}
a.promptActive = true
a.promptLabel = "Rename to:"
a.promptValue = item.Name
a.promptCursor = utf8.RuneCountInString(item.Name) // cursor at end
return a, nil
}
// isValidFilename checks that the name is a simple filename
// (no path separators, no parent directory references).
func isValidFilename(name string) bool {
if name == "" || name == ".." || name == "." {
return false
}
for _, ch := range name {
if ch == '/' || ch == '\\' {
return false
}
}
return true
}
func (a *App) doRename(newName string) (tea.Model, tea.Cmd) {
item, ok := a.currentFile()
if !ok {
return a, nil
}
// Validate: reject path traversal
if !isValidFilename(newName) {
a.message = "Invalid filename"
a.messageIsError = true
return a, nil
}
oldPath := item.Path
newPath := filepath.Join(a.cwd, newName)
// Check if target already exists (prevent silent overwrite)
if _, err := os.Stat(newPath); err == nil && newPath != oldPath {
a.confirmAction = "rename-overwrite"
a.confirmTarget = newName
// Stash the rename info for the confirm handler
a.pendingRenameOld = oldPath
a.pendingRenameNew = newName
return a, nil
}
return a, func() tea.Msg {
if err := os.Rename(oldPath, newPath); err != nil {
return RenameResultMsg{err: err}
}
op := &Operation{
Type: "rename",
Path: newPath,
OldPath: oldPath,
}
return RenameResultMsg{newName: newName, op: op}
}
}
// --- Git operations ---
func (a *App) gitStage() (tea.Model, tea.Cmd) {
if a.gitSvc == nil || !a.gitSvc.IsRepo() {
return a, nil
}
files := a.getSelectedFiles()
for _, f := range files {
rel := a.gitRepoRelPath(f)
if rel == "" {
continue
}
if err := a.gitSvc.Stage(rel); err != nil {
a.message = fmt.Sprintf("Error staging: %v", err)
a.messageIsError = true
return a, nil
}
}
a.message = fmt.Sprintf("Staged %d file(s)", len(files))
a.messageIsError = false
return a, tea.Batch(a.loadDir(), a.loadGitStatus())
}
func (a *App) gitUnstage() (tea.Model, tea.Cmd) {
if a.gitSvc == nil || !a.gitSvc.IsRepo() {
return a, nil
}
files := a.getSelectedFiles()
for _, f := range files {
rel := a.gitRepoRelPath(f)
if rel == "" {
continue
}
if err := a.gitSvc.Unstage(rel); err != nil {
a.message = fmt.Sprintf("Error unstaging: %v", err)
a.messageIsError = true
return a, nil
}
}
a.message = fmt.Sprintf("Unstaged %d file(s)", len(files))
a.messageIsError = false
return a, tea.Batch(a.loadDir(), a.loadGitStatus())
}
func (a *App) gitDiff() (tea.Model, tea.Cmd) {
if a.gitSvc == nil || !a.gitSvc.IsRepo() {
return a, nil
}
item, ok := a.currentFile()
if !ok {
return a, nil
}
rel := a.gitRepoRelPath(item.Path)
if rel == "" {
return a, nil
}
return a, func() tea.Msg {
diff, err := a.gitSvc.Diff(rel)
if err != nil {
return DiffMsg{diff: fmt.Sprintf("Error: %v", err), fileName: item.Name}
}
if diff == "" {
return DiffMsg{diff: "No changes", fileName: item.Name}
}
return DiffMsg{diff: diff, fileName: item.Name}
}
}
// --- Shell ---
func (a *App) openShell() (tea.Model, tea.Cmd) {
var shell string
var args []string
if runtime.GOOS == "windows" {
// Try PowerShell 7+ first, fall back to Windows PowerShell
shell = "powershell.exe"
if _, err := exec.LookPath("pwsh.exe"); err == nil {
shell = "pwsh.exe"
}
args = []string{"-NoExit", "-Command", fmt.Sprintf(`cd "%s"`, a.cwd)}
} else {
// Use $SHELL if set, otherwise fall back to bash
shell = os.Getenv("SHELL")
if shell == "" {
shell = "bash"
}
shellName := filepath.Base(shell)
escaped := strings.ReplaceAll(a.cwd, "'", "'\\''")
args = []string{"-c", fmt.Sprintf("cd '%s' && exec %s", escaped, shellName)}
}
cmd := exec.Command(shell, args...)
cmd.Dir = a.cwd
return a, tea.ExecProcess(cmd, func(err error) tea.Msg {
return ShellExitMsg{err: err}
})
}
// --- Create operations ---
func (a *App) startCreateFile() (tea.Model, tea.Cmd) {
a.promptActive = true
a.promptLabel = "New file:"
a.promptValue = ""
a.promptCursor = 0
return a, nil
}
func (a *App) startCreateDir() (tea.Model, tea.Cmd) {
a.promptActive = true
a.promptLabel = "New directory:"
a.promptValue = ""
a.promptCursor = 0
return a, nil
}
func (a *App) doCreateFile(name string) (tea.Model, tea.Cmd) {
path := filepath.Join(a.cwd, name)
// Check if file already exists
if _, err := os.Stat(path); err == nil {
a.promptActive = false
a.confirmAction = "create-overwrite"
a.confirmTarget = name
return a, nil
}
return a, func() tea.Msg {
f, err := os.Create(path)
if err != nil {
return CreateResultMsg{err: err}
}
f.Close()
return CreateResultMsg{name: name}
}
}
func (a *App) doCreateDir(name string) (tea.Model, tea.Cmd) {
path := filepath.Join(a.cwd, name)
return a, func() tea.Msg {
if err := os.Mkdir(path, 0755); err != nil {
return CreateResultMsg{err: err}
}
return CreateResultMsg{name: name + "/"}
}
}
// copyFile copies a file from src to dst.
func copyFile(src, dst string) error {
// Prevent self-copy (would truncate the file)
srcAbs, _ := filepath.Abs(src)
dstAbs, _ := filepath.Abs(dst)
if srcAbs == dstAbs {
return fmt.Errorf("source and destination are the same file")
}
sourceFile, err := os.Open(src)
if err != nil {
return err
}
defer sourceFile.Close()
info, err := sourceFile.Stat()
if err != nil {
return err
}
destFile, err := os.OpenFile(dst, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, info.Mode())
if err != nil {
return err
}
defer destFile.Close()
_, err = io.Copy(destFile, sourceFile)
return err
}
// --- Bookmark operations ---
// addBookmark adds the current directory to bookmarks if not already present.
func (a *App) addBookmark() (tea.Model, tea.Cmd) {
// Check if already bookmarked
for _, b := range a.config.Bookmarks {
if b == a.cwd {
a.message = "Already bookmarked"
a.messageIsError = false
return a, nil
}
}
a.config.Bookmarks = append(a.config.Bookmarks, a.cwd)
a.message = fmt.Sprintf("Bookmarked %s", a.cwd)
a.messageIsError = false
return a, nil
}
// removeBookmark removes the current directory from bookmarks.
func (a *App) removeBookmark() (tea.Model, tea.Cmd) {
for i, b := range a.config.Bookmarks {
if b == a.cwd {
a.config.Bookmarks = append(a.config.Bookmarks[:i], a.config.Bookmarks[i+1:]...)
a.message = "Bookmark removed"
a.messageIsError = false
return a, nil
}
}
a.message = "Not bookmarked"
a.messageIsError = false
return a, nil
}
// showBookmarks enters bookmark selection mode.
func (a *App) showBookmarks() (tea.Model, tea.Cmd) {
if len(a.config.Bookmarks) == 0 {
a.message = "No bookmarks"
a.messageIsError = false
return a, nil
}
a.bookmarkMode = true
a.bookmarkIndex = 0
return a, nil
}
// handleBookmarkKey handles key events in bookmark selection mode.
func (a *App) handleBookmarkKey(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
switch msg.String() {
case "esc", "q":
a.bookmarkMode = false
return a, nil
case "j", "down":
if a.bookmarkIndex < len(a.config.Bookmarks)-1 {
a.bookmarkIndex++
}
case "k", "up":
if a.bookmarkIndex > 0 {
a.bookmarkIndex--
}
case "enter", "l", "right":
// Navigate to selected bookmark
if a.bookmarkIndex >= 0 && a.bookmarkIndex < len(a.config.Bookmarks) {
a.cwd = a.config.Bookmarks[a.bookmarkIndex]
a.gitSvc = a.reuseOrNewGitService()
a.resetPreview()
}
a.bookmarkMode = false
return a, tea.Batch(a.loadDir(), a.loadGitStatus())
case "x":
// Remove bookmark
if a.bookmarkIndex >= 0 && a.bookmarkIndex < len(a.config.Bookmarks) {
a.config.Bookmarks = append(a.config.Bookmarks[:a.bookmarkIndex], a.config.Bookmarks[a.bookmarkIndex+1:]...)
if a.bookmarkIndex >= len(a.config.Bookmarks) && a.bookmarkIndex > 0 {
a.bookmarkIndex--
}
if len(a.config.Bookmarks) == 0 {
a.bookmarkMode = false
}
}
return a, nil
}
return a, nil
}
// --- Command palette ---
// commandItem represents a command in the command palette.
type commandItem struct {
name string
description string
action func() (tea.Model, tea.Cmd)
}
// getCommands returns all available commands for the command palette.
func (a *App) getCommands() []commandItem {
return []commandItem{
{"Toggle preview", "Show/hide preview panel", func() (tea.Model, tea.Cmd) {
a.showPreview = !a.showPreview
return a, nil
}},
{"Toggle hidden files", "Show/hide hidden files", func() (tea.Model, tea.Cmd) {
a.showHidden = !a.showHidden
a.config.ShowHidden = a.showHidden
return a, a.loadDir()
}},
{"Sort by name", "Sort files by name", func() (tea.Model, tea.Cmd) {
a.sortMode = SortByName
a.config.SortBy = "name"
return a, a.loadDir()
}},
{"Sort by size", "Sort files by size", func() (tea.Model, tea.Cmd) {
a.sortMode = SortBySize
a.config.SortBy = "size"
return a, a.loadDir()
}},
{"Sort by time", "Sort files by modification time", func() (tea.Model, tea.Cmd) {
a.sortMode = SortByModified
a.config.SortBy = "time"
return a, a.loadDir()
}},
{"Sort by type", "Sort files by extension", func() (tea.Model, tea.Cmd) {
a.sortMode = SortByType
a.config.SortBy = "type"
return a, a.loadDir()
}},
{"Add bookmark", "Bookmark current directory", func() (tea.Model, tea.Cmd) {
return a.addBookmark()
}},
{"Show bookmarks", "Open bookmark list", func() (tea.Model, tea.Cmd) {
return a.showBookmarks()
}},
{"New file", "Create a new file", func() (tea.Model, tea.Cmd) {
return a.startCreateFile()
}},
{"New directory", "Create a new directory", func() (tea.Model, tea.Cmd) {
return a.startCreateDir()
}},
{"Open shell", "Open terminal shell in current directory", func() (tea.Model, tea.Cmd) {
return a.openShell()
}},
{"Help", "Show help", func() (tea.Model, tea.Cmd) {
a.showHelp = true
return a, nil
}},
{"Quit", "Exit traverse", func() (tea.Model, tea.Cmd) {
a.config.ShowHidden = a.showHidden
a.config.PreviewEnabled = a.showPreview
if err := SaveConfig(a.config); err != nil {
fmt.Fprintf(os.Stderr, "Warning: failed to save config: %v\n", err)
}
return a, tea.Quit
}},
}
}
// showCommandPalette opens the command palette.
func (a *App) showCommandPalette() (tea.Model, tea.Cmd) {
a.commandPaletteMode = true
a.commandPaletteQuery = ""
a.commandPaletteIndex = 0
a.commandPaletteItems = a.getCommands()
return a, nil
}
// filterCommands returns commands matching the query.
func (a *App) filterCommands() []commandItem {
if a.commandPaletteQuery == "" {
return a.commandPaletteItems
}
query := strings.ToLower(a.commandPaletteQuery)
var result []commandItem
for _, cmd := range a.commandPaletteItems {
if strings.Contains(strings.ToLower(cmd.name), query) ||
strings.Contains(strings.ToLower(cmd.description), query) {
result = append(result, cmd)
}
}
return result
}
// handleCommandPaletteKey handles key events in the command palette.
func (a *App) handleCommandPaletteKey(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
filtered := a.filterCommands()
switch msg.String() {
case "esc":
a.commandPaletteMode = false
a.commandPaletteQuery = ""
return a, nil
case "enter":
// Execute selected command
if a.commandPaletteIndex >= 0 && a.commandPaletteIndex < len(filtered) {
cmd := filtered[a.commandPaletteIndex]
a.commandPaletteMode = false
a.commandPaletteQuery = ""
return cmd.action()
}
a.commandPaletteMode = false
return a, nil
case "up", "k":
if a.commandPaletteIndex > 0 {
a.commandPaletteIndex--
}
case "down", "j":
if a.commandPaletteIndex < len(filtered)-1 {
a.commandPaletteIndex++
}
case "backspace":
runes := []rune(a.commandPaletteQuery)
if len(runes) > 0 {
a.commandPaletteQuery = string(runes[:len(runes)-1])
a.commandPaletteIndex = 0
}
default:
s := msg.String()
if utf8.RuneCountInString(s) == 1 && s >= " " {
a.commandPaletteQuery += s
a.commandPaletteIndex = 0
}
}
return a, nil
}
// --- Undo operations ---
// moveFile moves a file across devices (copy + delete fallback).
func moveFile(src, dst string) error {
if err := os.Rename(src, dst); err != nil {
if err := copyFile(src, dst); err != nil {
return err
}
return os.Remove(src)
}
return nil
}
// undoLastOperation reverses the last operation in the undo stack.
func (a *App) undoLastOperation() (tea.Model, tea.Cmd) {
if len(a.undoStack) == 0 {
a.message = "Nothing to undo"
a.messageIsError = false
return a, nil
}
op := a.undoStack[len(a.undoStack)-1]
a.undoStack = a.undoStack[:len(a.undoStack)-1]
switch op.Type {
case "delete":
// Restore all files from backups (batch-aware)
var restored int
var lastErr error
for i, backup := range op.Backups {
origPath := op.Paths[i]
if err := moveFile(backup, origPath); err != nil {
lastErr = err
continue
}
restored++
}
if lastErr != nil {
a.message = fmt.Sprintf("Restored %d/%d files: %v", restored, len(op.Backups), lastErr)
a.messageIsError = true
} else if restored == 1 {
a.message = fmt.Sprintf("Restored %s", filepath.Base(op.Paths[0]))
a.messageIsError = false
} else {
a.message = fmt.Sprintf("Restored %d files", restored)
a.messageIsError = false
}
case "rename":
// Rename back to original path
if err := moveFile(op.Path, op.OldPath); err != nil {
a.message = fmt.Sprintf("Undo failed: %v", err)
a.messageIsError = true
return a, nil
}
a.message = fmt.Sprintf("Renamed back to %s", filepath.Base(op.OldPath))
a.messageIsError = false
}
return a, tea.Batch(a.loadDir(), a.loadGitStatus())
}