diff --git a/cmd/serve/nfs/nfs.go b/cmd/serve/nfs/nfs.go index 22b263308..4deb399a8 100644 --- a/cmd/serve/nfs/nfs.go +++ b/cmd/serve/nfs/nfs.go @@ -15,7 +15,6 @@ import ( "github.com/rclone/rclone/cmd" "github.com/rclone/rclone/fs" "github.com/rclone/rclone/fs/config/flags" - "github.com/rclone/rclone/fs/rc" "github.com/rclone/rclone/vfs" "github.com/rclone/rclone/vfs/vfscommon" "github.com/rclone/rclone/vfs/vfsflags" @@ -23,19 +22,32 @@ import ( "github.com/spf13/pflag" ) +// OptionsInfo descripts the Options in use +var OptionsInfo = fs.Options{{ + Name: "addr", + Default: "", + Help: "IPaddress:Port or :Port to bind server to", +}, { + Name: "nfs_cache_handle_limit", + Default: 1000000, + Help: "max file handles cached simultaneously (min 5)", +}} + +func init() { + fs.RegisterGlobalOptions(fs.OptionsInfo{Name: "nfs", Opt: &opt, Options: OptionsInfo}) +} + // Options contains options for the NFS Server type Options struct { - ListenAddr string // Port to listen on - HandleLimit int // max file handles cached by go-nfs CachingHandler + ListenAddr string `config:"addr"` // Port to listen on + HandleLimit int `config:"nfs_cache_handle_limit"` // max file handles cached by go-nfs CachingHandler } var opt Options // AddFlags adds flags for serve nfs (and nfsmount) func AddFlags(flagSet *pflag.FlagSet, Opt *Options) { - rc.AddOption("nfs", &Opt) - flags.StringVarP(flagSet, &Opt.ListenAddr, "addr", "", Opt.ListenAddr, "IPaddress:Port or :Port to bind server to", "") - flags.IntVarP(flagSet, &Opt.HandleLimit, "nfs-cache-handle-limit", "", 1000000, "max file handles cached simultaneously (min 5)", "") + flags.AddFlagsFromOptions(flagSet, "", OptionsInfo) } func init() {