Added support for toggling each of audio|image|video support
This commit is contained in:
parent
32bd20522a
commit
2f1cfe28d0
|
@ -108,12 +108,14 @@ Usage:
|
||||||
roulette <path> [path]... [flags]
|
roulette <path> [path]... [flags]
|
||||||
|
|
||||||
Flags:
|
Flags:
|
||||||
|
--audio enable support for audio files
|
||||||
-b, --bind string address to bind to (default "0.0.0.0")
|
-b, --bind string address to bind to (default "0.0.0.0")
|
||||||
-c, --cache generate directory cache at startup
|
-c, --cache generate directory cache at startup
|
||||||
--cache-file string path to optional persistent cache file
|
--cache-file string path to optional persistent cache file
|
||||||
-d, --debug expose debug endpoint
|
-d, --debug expose debug endpoint
|
||||||
-f, --filter enable filtering
|
-f, --filter enable filtering
|
||||||
-h, --help help for roulette
|
-h, --help help for roulette
|
||||||
|
--images enable support for audio files (default true)
|
||||||
--maximum-files uint32 skip directories with file counts over this value (default 4294967295)
|
--maximum-files uint32 skip directories with file counts over this value (default 4294967295)
|
||||||
--minimum-files uint32 skip directories with file counts under this value
|
--minimum-files uint32 skip directories with file counts under this value
|
||||||
--page-length uint16 pagination length for statistics and debug pages
|
--page-length uint16 pagination length for statistics and debug pages
|
||||||
|
@ -121,12 +123,13 @@ Flags:
|
||||||
--profile register net/http/pprof handlers
|
--profile register net/http/pprof handlers
|
||||||
-r, --recursive recurse into subdirectories
|
-r, --recursive recurse into subdirectories
|
||||||
--refresh-interval string force refresh interval equal to this duration (minimum 500ms)
|
--refresh-interval string force refresh interval equal to this duration (minimum 500ms)
|
||||||
--russian remove selected media after serving
|
--russian remove selected images after serving
|
||||||
-s, --sort enable sorting
|
-s, --sort enable sorting
|
||||||
--stats expose stats endpoint
|
--stats expose stats endpoint
|
||||||
--stats-file string path to optional persistent stats file
|
--stats-file string path to optional persistent stats file
|
||||||
-v, --verbose log accessed files to stdout
|
-v, --verbose log accessed files to stdout
|
||||||
-V, --version display version and exit
|
-V, --version display version and exit
|
||||||
|
--videos enable support for video files
|
||||||
```
|
```
|
||||||
|
|
||||||
## Building the Docker container
|
## Building the Docker container
|
||||||
|
|
|
@ -405,9 +405,9 @@ func fileType(path string) (bool, string, string, error) {
|
||||||
switch {
|
switch {
|
||||||
case filetype.IsAudio(head) && audio:
|
case filetype.IsAudio(head) && audio:
|
||||||
return true, "audio", fileType.MIME.Value, nil
|
return true, "audio", fileType.MIME.Value, nil
|
||||||
case filetype.IsImage(head):
|
case filetype.IsImage(head) && images:
|
||||||
return true, "image", fileType.MIME.Value, nil
|
return true, "image", fileType.MIME.Value, nil
|
||||||
case filetype.IsVideo(head) && video:
|
case filetype.IsVideo(head) && videos:
|
||||||
return true, "video", fileType.MIME.Value, nil
|
return true, "video", fileType.MIME.Value, nil
|
||||||
default:
|
default:
|
||||||
return false, "", "", nil
|
return false, "", "", nil
|
||||||
|
|
14
cmd/root.go
14
cmd/root.go
|
@ -17,7 +17,7 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Version string = "0.62.0"
|
Version string = "0.63.0"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -27,6 +27,7 @@ var (
|
||||||
cacheFile string
|
cacheFile string
|
||||||
debug bool
|
debug bool
|
||||||
filtering bool
|
filtering bool
|
||||||
|
images bool
|
||||||
maximumFileCount uint32
|
maximumFileCount uint32
|
||||||
minimumFileCount uint32
|
minimumFileCount uint32
|
||||||
pageLength uint16
|
pageLength uint16
|
||||||
|
@ -40,11 +41,11 @@ var (
|
||||||
statisticsFile string
|
statisticsFile string
|
||||||
verbose bool
|
verbose bool
|
||||||
version bool
|
version bool
|
||||||
video bool
|
videos bool
|
||||||
|
|
||||||
rootCmd = &cobra.Command{
|
rootCmd = &cobra.Command{
|
||||||
Use: "roulette <path> [path]...",
|
Use: "roulette <path> [path]...",
|
||||||
Short: "Serves random images from the specified directories.",
|
Short: "Serves random media from the specified directories.",
|
||||||
Args: cobra.MinimumNArgs(1),
|
Args: cobra.MinimumNArgs(1),
|
||||||
PreRun: func(cmd *cobra.Command, args []string) {
|
PreRun: func(cmd *cobra.Command, args []string) {
|
||||||
if debug {
|
if debug {
|
||||||
|
@ -77,12 +78,13 @@ func Execute() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.Flags().BoolVar(&audio, "audio", false, "additionally support audio files")
|
rootCmd.Flags().BoolVar(&audio, "audio", false, "enable support for audio files")
|
||||||
rootCmd.Flags().StringVarP(&bind, "bind", "b", "0.0.0.0", "address to bind to")
|
rootCmd.Flags().StringVarP(&bind, "bind", "b", "0.0.0.0", "address to bind to")
|
||||||
rootCmd.Flags().BoolVarP(&cache, "cache", "c", false, "generate directory cache at startup")
|
rootCmd.Flags().BoolVarP(&cache, "cache", "c", false, "generate directory cache at startup")
|
||||||
rootCmd.Flags().StringVar(&cacheFile, "cache-file", "", "path to optional persistent cache file")
|
rootCmd.Flags().StringVar(&cacheFile, "cache-file", "", "path to optional persistent cache file")
|
||||||
rootCmd.Flags().BoolVarP(&debug, "debug", "d", false, "expose debug endpoint")
|
rootCmd.Flags().BoolVarP(&debug, "debug", "d", false, "expose debug endpoint")
|
||||||
rootCmd.Flags().BoolVarP(&filtering, "filter", "f", false, "enable filtering")
|
rootCmd.Flags().BoolVarP(&filtering, "filter", "f", false, "enable filtering")
|
||||||
|
rootCmd.Flags().BoolVar(&images, "images", true, "enable support for audio files")
|
||||||
rootCmd.Flags().Uint32Var(&maximumFileCount, "maximum-files", 1<<32-1, "skip directories with file counts over this value")
|
rootCmd.Flags().Uint32Var(&maximumFileCount, "maximum-files", 1<<32-1, "skip directories with file counts over this value")
|
||||||
rootCmd.Flags().Uint32Var(&minimumFileCount, "minimum-files", 0, "skip directories with file counts under this value")
|
rootCmd.Flags().Uint32Var(&minimumFileCount, "minimum-files", 0, "skip directories with file counts under this value")
|
||||||
rootCmd.Flags().Uint16Var(&pageLength, "page-length", 0, "pagination length for statistics and debug pages")
|
rootCmd.Flags().Uint16Var(&pageLength, "page-length", 0, "pagination length for statistics and debug pages")
|
||||||
|
@ -96,14 +98,12 @@ func init() {
|
||||||
rootCmd.Flags().StringVar(&statisticsFile, "stats-file", "", "path to optional persistent stats file")
|
rootCmd.Flags().StringVar(&statisticsFile, "stats-file", "", "path to optional persistent stats file")
|
||||||
rootCmd.Flags().BoolVarP(&verbose, "verbose", "v", false, "log accessed files to stdout")
|
rootCmd.Flags().BoolVarP(&verbose, "verbose", "v", false, "log accessed files to stdout")
|
||||||
rootCmd.Flags().BoolVarP(&version, "version", "V", false, "display version and exit")
|
rootCmd.Flags().BoolVarP(&version, "version", "V", false, "display version and exit")
|
||||||
rootCmd.Flags().BoolVar(&video, "video", false, "additionally support video files")
|
rootCmd.Flags().BoolVar(&videos, "videos", false, "enable support for video files")
|
||||||
|
|
||||||
rootCmd.Flags().SetInterspersed(true)
|
rootCmd.Flags().SetInterspersed(true)
|
||||||
|
|
||||||
rootCmd.CompletionOptions.HiddenDefaultCmd = true
|
rootCmd.CompletionOptions.HiddenDefaultCmd = true
|
||||||
|
|
||||||
// rootCmd.MarkFlagsMutuallyExclusive("cache", "russian")
|
|
||||||
|
|
||||||
rootCmd.SilenceErrors = true
|
rootCmd.SilenceErrors = true
|
||||||
rootCmd.SetHelpCommand(&cobra.Command{
|
rootCmd.SetHelpCommand(&cobra.Command{
|
||||||
Hidden: true,
|
Hidden: true,
|
||||||
|
|
Loading…
Reference in New Issue