From 644adc2c9d63c5f4e0432dd574b7ee97f166c3b5 Mon Sep 17 00:00:00 2001 From: plastikfan Date: Thu, 28 Dec 2023 20:39:43 +0000 Subject: [PATCH] feat(nav): add skim/depth flags (#79) --- go.mod | 8 +++---- go.sum | 18 +++++++-------- src/app/command/root-cmd.go | 10 +++++++++ src/app/command/shrink-cmd_test.go | 36 ++++++++++++++++++++++++++++++ src/app/proxy/image-defs.go | 1 + 5 files changed, 59 insertions(+), 14 deletions(-) diff --git a/go.mod b/go.mod index 38a870d..a9024b5 100644 --- a/go.mod +++ b/go.mod @@ -7,10 +7,10 @@ require ( github.com/onsi/gomega v1.30.0 github.com/pkg/errors v0.9.1 github.com/samber/lo v1.39.0 - github.com/snivilised/extendio v0.5.1 + github.com/snivilised/extendio v0.5.2 github.com/snivilised/lorax v0.4.2 github.com/spf13/cobra v1.8.0 - github.com/spf13/viper v1.18.1 + github.com/spf13/viper v1.18.2 go.uber.org/zap v1.26.0 ) @@ -20,7 +20,7 @@ require ( github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/google/pprof v0.0.0-20231212022811-ec68065c825e // indirect - github.com/google/uuid v1.4.0 // indirect + github.com/google/uuid v1.5.0 // indirect github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect github.com/onsi/ginkgo v1.16.5 // indirect github.com/sagikazarmark/locafero v0.4.0 // indirect @@ -41,7 +41,7 @@ require ( github.com/natefinch/lumberjack v2.0.0+incompatible github.com/nicksnyder/go-i18n/v2 v2.3.0 // indirect github.com/pelletier/go-toml/v2 v2.1.1 // indirect - github.com/snivilised/cobrass v0.4.1 + github.com/snivilised/cobrass v0.4.2 github.com/spf13/afero v1.11.0 // indirect github.com/spf13/cast v1.6.0 // indirect github.com/spf13/pflag v1.0.5 diff --git a/go.sum b/go.sum index ad12af1..083698d 100644 --- a/go.sum +++ b/go.sum @@ -38,8 +38,8 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/pprof v0.0.0-20231212022811-ec68065c825e h1:bwOy7hAFd0C91URzMIEBfr6BAz29yk7Qj0cy6S7DJlU= github.com/google/pprof v0.0.0-20231212022811-ec68065c825e/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= -github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4= -github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU= +github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= @@ -88,12 +88,10 @@ github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6g github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ= github.com/samber/lo v1.39.0 h1:4gTz1wUhNYLhFSKl6O+8peW0v2F4BCY034GRpU9WnuA= github.com/samber/lo v1.39.0/go.mod h1:+m/ZKRl6ClXCE2Lgf3MsQlWfh4bn1bz6CXEOxnEXnEA= -github.com/snivilised/cobrass v0.4.1 h1:0CpC6eIIxj/x7UW3Ba3BCP35LyEamslOaimGxlTwGSk= -github.com/snivilised/cobrass v0.4.1/go.mod h1:WFbmSiPNREW3cP3cuZ3EJrDgMUKgHQw13RNv6rCgyoo= -github.com/snivilised/extendio v0.5.0 h1:XxUW125nGxkluVOekzWWpoE80r5KL0e+MFP2gjiXOhc= -github.com/snivilised/extendio v0.5.0/go.mod h1:jBaeTO9432bNbBKR4mbt2d7OGyrDPY/U45siM3VhTks= -github.com/snivilised/extendio v0.5.1 h1:CHvhyTboVOHLj8rm0ZF5dm3jPViHKPAKQxvnI8WzqAo= -github.com/snivilised/extendio v0.5.1/go.mod h1:jBaeTO9432bNbBKR4mbt2d7OGyrDPY/U45siM3VhTks= +github.com/snivilised/cobrass v0.4.2 h1:V2LqFKZWYqdewSRPeLFqyKPfOr96ihs4+ixSnP/528U= +github.com/snivilised/cobrass v0.4.2/go.mod h1:bweMGepAjflKLqlCLkGi+Jvdru6ttdOr3L75rKq2yA8= +github.com/snivilised/extendio v0.5.2 h1:gpaA5hGM0DCyY1PHy51fnmAI76tzCOOo4rteyuWSTDI= +github.com/snivilised/extendio v0.5.2/go.mod h1:Ctp0GkEwMJ51FmgJE9nLLv86VTWILzgILdTgAeQ+BME= github.com/snivilised/lorax v0.4.2 h1:jPo+o4cP/BUYBkR6sg3oLybHx0j2R+0wMLnvOf/gh0g= github.com/snivilised/lorax v0.4.2/go.mod h1:vyhM905Fc4fzShAXPvykS8ZRnO6B85hd0emJgZE4iNY= github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= @@ -106,8 +104,8 @@ github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/spf13/viper v1.18.1 h1:rmuU42rScKWlhhJDyXZRKJQHXFX02chSVW1IvkPGiVM= -github.com/spf13/viper v1.18.1/go.mod h1:EKmWIqdnk5lOcmR72yw6hS+8OPYcwD0jteitLMVB+yk= +github.com/spf13/viper v1.18.2 h1:LUXCnvUvSM6FXAsj6nnfc8Q2tp1dIgUfY9Kc8GsSOiQ= +github.com/spf13/viper v1.18.2/go.mod h1:EKmWIqdnk5lOcmR72yw6hS+8OPYcwD0jteitLMVB+yk= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= diff --git a/src/app/command/root-cmd.go b/src/app/command/root-cmd.go index 5ad84f5..4102b3c 100644 --- a/src/app/command/root-cmd.go +++ b/src/app/command/root-cmd.go @@ -20,6 +20,7 @@ const ( WorkerPoolFamName = "worker-pool-family" FoldersFamName = "folders-family" ProfileFamName = "profile-family" + CascadeFamName = "cascade-family" ) func Execute() error { @@ -124,6 +125,11 @@ func (b *Bootstrap) buildRootCommand(container *assistant.CobraContainer) { profileFam := assistant.NewParamSet[store.ProfileParameterSet](rootCommand) profileFam.Native.BindAll(profileFam, rootCommand.PersistentFlags()) + // family: cascade [--depth, --skim(K)] + // + cascadeFam := assistant.NewParamSet[store.CascadeParameterSet](rootCommand) + cascadeFam.Native.BindAll(cascadeFam, rootCommand.PersistentFlags()) + // ??? rootCommand.Args = validatePositionalArgs container.MustRegisterParamSet(RootPsName, paramSet) @@ -131,6 +137,7 @@ func (b *Bootstrap) buildRootCommand(container *assistant.CobraContainer) { container.MustRegisterParamSet(WorkerPoolFamName, workerPoolFam) container.MustRegisterParamSet(FoldersFamName, foldersFam) container.MustRegisterParamSet(ProfileFamName, profileFam) + container.MustRegisterParamSet(CascadeFamName, cascadeFam) } func (b *Bootstrap) getRootInputs() *proxy.RootCommandInputs { @@ -150,5 +157,8 @@ func (b *Bootstrap) getRootInputs() *proxy.RootCommandInputs { ProfileFam: b.Container.MustGetParamSet( ProfileFamName, ).(*assistant.ParamSet[store.ProfileParameterSet]), + CascadeFam: b.Container.MustGetParamSet( + CascadeFamName, + ).(*assistant.ParamSet[store.CascadeParameterSet]), } } diff --git a/src/app/command/shrink-cmd_test.go b/src/app/command/shrink-cmd_test.go index 615ac61..875175a 100644 --- a/src/app/command/shrink-cmd_test.go +++ b/src/app/command/shrink-cmd_test.go @@ -178,6 +178,42 @@ var _ = Describe("ShrinkCmd", Ordered, func() { }, }, }), + + Entry(nil, &shrinkTE{ + commandTE: commandTE{ + message: "vanilla with long form skim", + args: []string{ + "--strip", + "--interlace", "plane", + "--quality", "85", + "--skim", + }, + }, + }), + + Entry(nil, &shrinkTE{ + commandTE: commandTE{ + message: "vanilla with short form skim", + args: []string{ + "--strip", + "--interlace", "plane", + "--quality", "85", + "-K", + }, + }, + }), + + Entry(nil, &shrinkTE{ + commandTE: commandTE{ + message: "vanilla with depth", + args: []string{ + "--strip", + "--interlace", "plane", + "--quality", "85", + "--depth", "1", + }, + }, + }), ) // NB: these tests are required because state does not work with diff --git a/src/app/proxy/image-defs.go b/src/app/proxy/image-defs.go index d9d8c09..c313818 100644 --- a/src/app/proxy/image-defs.go +++ b/src/app/proxy/image-defs.go @@ -127,6 +127,7 @@ type RootCommandInputs struct { WorkerPoolFam *assistant.ParamSet[store.WorkerPoolParameterSet] FoldersFam *assistant.ParamSet[store.FoldersFilterParameterSet] ProfileFam *assistant.ParamSet[store.ProfileParameterSet] + CascadeFam *assistant.ParamSet[store.CascadeParameterSet] } type ShrinkCommandInputs struct {