Skip to content

Commit e64965f

Browse files
committed
feat: enable ui by arg. fix missing yaml key
1 parent fa62c0d commit e64965f

File tree

4 files changed

+39
-36
lines changed

4 files changed

+39
-36
lines changed

README.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ With its tiny file size, FlyDav is the ideal solution for users who require a fa
88

99
The goal of FlyDav is to keep things easy and simple, with users able to deploy the service in no time. Therefore any extraneous features are not added, thus avoiding bloat.
1010

11-
1211
## One-Run install
1312

1413
**WARN** Only tested for AMD64 Linux with systemd. Enhancement PR is welcomed.
@@ -46,13 +45,14 @@ We provided a simple web page client, which supports browsing and downloading fi
4645
```bash
4746
$ flydav -h
4847
--------------------------------------------------------------------------------
49-
Usage: flydav [--host HOST] [--port PORT] [--user USER] [--verbose] [--config CONFIG]
48+
Usage: flydav [--host HOST] [--port PORT] [--user USER] [--verbose] [--config CONFIG] [--with-ui] [--help] [--version]
5049

5150
Options:
5251
--host HOST, -H HOST host address
5352
--port PORT, -p PORT port
5453
--user USER, -u USER username
5554
--verbose, -v verbose output
55+
--with-ui enable web ui
5656
--config CONFIG, -c CONFIG
5757
config file
5858
--help, -h display this help and exit
@@ -144,7 +144,6 @@ Simply add a new location as follow:
144144

145145
![image](https://github.com/pluveto/flydav/assets/50045289/bcd02371-5baf-45a8-ad84-702bfc29d971)
146146

147-
148147
## License
149148

150149
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details

cmd/flydav/app/args.go

+1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ type Args struct {
66
Username string `arg:"-u,--user" help:"username"`
77
Verbose bool `arg:"-v,--verbose" help:"verbose output"`
88
Config string `arg:"-c,--config" help:"config file"`
9+
EnabledUI bool `arg:"--with-ui" help:"enable web ui"`
910
}

cmd/flydav/conf/conf.go

+33-33
Original file line numberDiff line numberDiff line change
@@ -60,52 +60,52 @@ func GetDefaultConf() Conf {
6060
}
6161

6262
type Conf struct {
63-
Log Log `toml:"log"`
64-
Server Server `toml:"server"`
65-
Auth Auth `toml:"auth"`
66-
UI UI `toml:"ui"`
67-
CORS CORS `toml:"cors"`
63+
Log Log `toml:"log" yaml:"log"`
64+
Server Server `toml:"server" yaml:"server"`
65+
Auth Auth `toml:"auth" yaml:"auth"`
66+
UI UI `toml:"ui" yaml:"ui"`
67+
CORS CORS `toml:"cors" yaml:"cors"`
6868
}
6969

7070
type CORS struct {
71-
Enabled bool `toml:"enabled"`
72-
AllowedOrigins []string `toml:"allowed_origins"`
73-
AllowedMethods []string `toml:"allowed_methods"`
74-
AllowedHeaders []string `toml:"allowed_headers"`
75-
ExposedHeaders []string `toml:"exposed_headers"`
76-
AllowCredentials bool `toml:"allow_credentials"`
71+
Enabled bool `toml:"enabled" yaml:"enabled"`
72+
AllowedOrigins []string `toml:"allowed_origins" yaml:"allowed_origins"`
73+
AllowedMethods []string `toml:"allowed_methods" yaml:"allowed_methods"`
74+
AllowedHeaders []string `toml:"allowed_headers" yaml:"allowed_headers"`
75+
ExposedHeaders []string `toml:"exposed_headers" yaml:"exposed_headers"`
76+
AllowCredentials bool `toml:"allow_credentials" yaml:"allow_credentials"`
7777
MaxAge int
7878
}
7979

8080
type Server struct {
81-
Host string `toml:"host"`
82-
Port int `toml:"port"`
83-
Path string `toml:"path"`
84-
FsDir string `toml:"fs_dir"`
81+
Host string `toml:"host" yaml:"host"`
82+
Port int `toml:"port" yaml:"port"`
83+
Path string `toml:"path" yaml:"path"`
84+
FsDir string `toml:"fs_dir" yaml:"fs_dir"`
8585
}
8686

8787
type UI struct {
88-
Enabled bool `toml:"enabled"`
89-
Path string `toml:"path"` // Path prefix. TODO: ui.path cannot equals to server.path
90-
Source string `toml:"source"` // Source location of the UI
88+
Enabled bool `toml:"enabled" yaml:"enabled"`
89+
Path string `toml:"path" yaml:"path"` // Path prefix. TODO: ui.path cannot equals to server.path
90+
Source string `toml:"source" yaml:"source"` // Source location of the UI
9191
}
9292

9393
type User struct {
94-
SubPath string `toml:"sub_path"`
95-
SubFsDir string `toml:"sub_fs_dir"`
96-
Username string `toml:"username"`
97-
PasswordHash string `toml:"password_hash"`
98-
PasswordCrypt HashMethond `toml:"password_crypt"`
94+
SubPath string `toml:"sub_path" yaml:"sub_path"`
95+
SubFsDir string `toml:"sub_fs_dir" yaml:"sub_fs_dir"`
96+
Username string `toml:"username" yaml:"username"`
97+
PasswordHash string `toml:"password_hash" yaml:"password_hash"`
98+
PasswordCrypt HashMethond `toml:"password_crypt" yaml:"password_crypt"`
9999
}
100100
type Auth struct {
101-
User []User `toml:"user"`
101+
User []User `toml:"user" yaml:"user"`
102102
}
103103

104104
type File struct {
105-
Format LogFormat `toml:"format"`
106-
Path string `toml:"path"`
107-
MaxSize int `toml:"max_size"`
108-
MaxAge int `toml:"max_age"`
105+
Format LogFormat `toml:"format" yaml:"format"`
106+
Path string `toml:"path" yaml:"path"`
107+
MaxSize int `toml:"max_size" yaml:"max_size"`
108+
MaxAge int `toml:"max_age" yaml:"max_age"`
109109
}
110110

111111
type LogFormat string
@@ -124,11 +124,11 @@ const (
124124
)
125125

126126
type Stdout struct {
127-
Format LogFormat `toml:"format"`
128-
Output LogOutput `toml:"output"`
127+
Format LogFormat `toml:"format" yaml:"format"`
128+
Output LogOutput `toml:"output" yaml:"output"`
129129
}
130130
type Log struct {
131-
Level string `toml:"level"`
132-
File []File `toml:"file"`
133-
Stdout []Stdout `toml:"stdout"`
131+
Level string `toml:"level" yaml:"level"`
132+
File []File `toml:"file" yaml:"file"`
133+
Stdout []Stdout `toml:"stdout" yaml:"stdout"`
134134
}

cmd/flydav/main.go

+3
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ func overrideConf(cnf *conf.Conf, args app.Args) {
6767
},
6868
}
6969
}
70+
if args.EnabledUI {
71+
cnf.UI.Enabled = true
72+
}
7073
}
7174

7275
func promptPassword(username string) string {

0 commit comments

Comments
 (0)