Skip to content

Commit 14620b3

Browse files
committed
user can enter the path, which will be the path of the first file panel
1 parent 4870ce1 commit 14620b3

File tree

3 files changed

+27
-9
lines changed

3 files changed

+27
-9
lines changed

Diff for: changelog.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ All notable changes to this project will be documented in this file. Dates are d
1010

1111
- Update `$HOME/.superfile` to `$HOME/.config/superfile` [`886dbfb`](https://github.com/MHNightCat/superfile/commit/886dbfb276407db36e9fb7369ec31053e7aabcf4)
1212
- Follow [The FreeDesktop.org Trash specification](https://specifications.freedesktop.org/trash-spec/trashspec-1.0.html) to update the trash bin path [`886dbfb`](https://github.com/MHNightCat/superfile/commit/886dbfb276407db36e9fb7369ec31053e7aabcf4)
13-
13+
- Follow [The FreeDesktop.org Trash specification](https://specifications.freedesktop.org/trash-spec/trashspec-1.0.html) to update the trash bin path [`886dbfb`](https://github.com/MHNightCat/superfile/commit/886dbfb276407db36e9fb7369ec31053e7aabcf4)
14+
- The user can enter the path, which will be the path of the first file panel [``]()
1415
#### Bug fix
1516

1617
- Fix processes bar cursor index display error [`f6eb9d8`](https://github.com/MHNightCat/superfile/commit/f6eb9d879f9f7ef31859e3f84c8792e2f0fc543a)

Diff for: src/components/model.go

+13-4
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ package components
22

33
import (
44
"encoding/json"
5+
"log"
6+
"os"
7+
"path/filepath"
8+
59
"github.com/barasher/go-exiftool"
610
"github.com/charmbracelet/bubbles/textinput"
711
tea "github.com/charmbracelet/bubbletea"
812
"github.com/charmbracelet/lipgloss"
9-
"log"
10-
"os"
1113
)
1214

1315
const (
@@ -32,7 +34,7 @@ var et *exiftool.Exiftool
3234

3335
var processBarChannel = make(chan processBarMessage, 1000)
3436

35-
func InitialModel() model {
37+
func InitialModel(dir string) model {
3638
var err error
3739
logOutput, err = os.OpenFile(SuperFileMainDir+logFile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
3840
if err != nil {
@@ -66,6 +68,13 @@ func InitialModel() model {
6668
if err != nil {
6769
OutPutLog("Initia model function init exiftool error", err)
6870
}
71+
firstFilePanelDir := HomeDir
72+
if dir != "" {
73+
firstFilePanelDir, err = filepath.Abs(dir)
74+
if err != nil {
75+
firstFilePanelDir = HomeDir
76+
}
77+
}
6978
return model{
7079
filePanelFocusIndex: 0,
7180
focusPanel: nonePanelFocus,
@@ -84,7 +93,7 @@ func InitialModel() model {
8493
{
8594
render: 0,
8695
cursor: 0,
87-
location: HomeDir,
96+
location: firstFilePanelDir,
8897
panelMode: browserMode,
8998
focusType: focus,
9099
folderRecord: make(map[string]folderRecord),

Diff for: src/main.go

+12-4
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,27 @@ type GitHubRelease struct {
4646
func main() {
4747
app := &cli.App{
4848
Name: "superfile",
49-
Version: currentVersion,
49+
Version: currentVersion, // 假设你有一个变量currentVersion
5050
Description: "A Modern file manager with golang",
51-
Flags: []cli.Flag{},
51+
ArgsUsage: "[path]", // 定义命令行参数的使用方式
5252
Action: func(c *cli.Context) error {
53+
// 获取用户输入的路径,如果没有输入,则默认为当前目录
54+
path := ""
55+
if c.Args().Present() {
56+
path = c.Args().First()
57+
}
58+
59+
// 初始化配置文件
5360
InitConfigFile()
54-
p := tea.NewProgram(components.InitialModel(), tea.WithAltScreen())
61+
62+
// 使用获取到的路径初始化你的文件管理器
63+
p := tea.NewProgram(components.InitialModel(path), tea.WithAltScreen())
5564
if _, err := p.Run(); err != nil {
5665
fmt.Printf("Alas, there's been an error: %v", err)
5766
os.Exit(1)
5867
}
5968
CheckForUpdates()
6069
return nil
61-
6270
},
6371
}
6472

0 commit comments

Comments
 (0)