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]
|
||||
|
||||
Flags:
|
||||
--audio enable support for audio files
|
||||
-b, --bind string address to bind to (default "0.0.0.0")
|
||||
-c, --cache generate directory cache at startup
|
||||
--cache-file string path to optional persistent cache file
|
||||
-d, --debug expose debug endpoint
|
||||
-f, --filter enable filtering
|
||||
-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)
|
||||
--minimum-files uint32 skip directories with file counts under this value
|
||||
--page-length uint16 pagination length for statistics and debug pages
|
||||
|
@ -121,12 +123,13 @@ Flags:
|
|||
--profile register net/http/pprof handlers
|
||||
-r, --recursive recurse into subdirectories
|
||||
--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
|
||||
--stats expose stats endpoint
|
||||
--stats-file string path to optional persistent stats file
|
||||
-v, --verbose log accessed files to stdout
|
||||
-V, --version display version and exit
|
||||
--videos enable support for video files
|
||||
```
|
||||
|
||||
## Building the Docker container
|
||||
|
|
|
@ -405,9 +405,9 @@ func fileType(path string) (bool, string, string, error) {
|
|||
switch {
|
||||
case filetype.IsAudio(head) && audio:
|
||||
return true, "audio", fileType.MIME.Value, nil
|
||||
case filetype.IsImage(head):
|
||||
case filetype.IsImage(head) && images:
|
||||
return true, "image", fileType.MIME.Value, nil
|
||||
case filetype.IsVideo(head) && video:
|
||||
case filetype.IsVideo(head) && videos:
|
||||
return true, "video", fileType.MIME.Value, nil
|
||||
default:
|
||||
return false, "", "", nil
|
||||
|
|
14
cmd/root.go
14
cmd/root.go
|
@ -17,7 +17,7 @@ var (
|
|||
)
|
||||
|
||||
const (
|
||||
Version string = "0.62.0"
|
||||
Version string = "0.63.0"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -27,6 +27,7 @@ var (
|
|||
cacheFile string
|
||||
debug bool
|
||||
filtering bool
|
||||
images bool
|
||||
maximumFileCount uint32
|
||||
minimumFileCount uint32
|
||||
pageLength uint16
|
||||
|
@ -40,11 +41,11 @@ var (
|
|||
statisticsFile string
|
||||
verbose bool
|
||||
version bool
|
||||
video bool
|
||||
videos bool
|
||||
|
||||
rootCmd = &cobra.Command{
|
||||
Use: "roulette <path> [path]...",
|
||||
Short: "Serves random images from the specified directories.",
|
||||
Short: "Serves random media from the specified directories.",
|
||||
Args: cobra.MinimumNArgs(1),
|
||||
PreRun: func(cmd *cobra.Command, args []string) {
|
||||
if debug {
|
||||
|
@ -77,12 +78,13 @@ func Execute() {
|
|||
}
|
||||
|
||||
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().BoolVarP(&cache, "cache", "c", false, "generate directory cache at startup")
|
||||
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(&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(&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")
|
||||
|
@ -96,14 +98,12 @@ func init() {
|
|||
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(&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.CompletionOptions.HiddenDefaultCmd = true
|
||||
|
||||
// rootCmd.MarkFlagsMutuallyExclusive("cache", "russian")
|
||||
|
||||
rootCmd.SilenceErrors = true
|
||||
rootCmd.SetHelpCommand(&cobra.Command{
|
||||
Hidden: true,
|
||||
|
|
Loading…
Reference in New Issue