From aa2b92b7bb3a790d5d157dac95706a390ca4997c Mon Sep 17 00:00:00 2001 From: ayyansea Date: Tue, 3 Dec 2024 22:56:30 +0300 Subject: feat: add -f argument and filter appending logic --- cmd/uptfs/main.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/cmd/uptfs/main.go b/cmd/uptfs/main.go index 5738131..5bc1a54 100644 --- a/cmd/uptfs/main.go +++ b/cmd/uptfs/main.go @@ -15,8 +15,9 @@ import ( ) var args struct { - ConfigFile string `arg:"-c" help:"path to config file" default:""` - Verbose bool `arg:"-v" help:"toggle verbose (debug) mode"` + ConfigFile string `arg:"-c" help:"path to config file" default:""` + Verbose bool `arg:"-v" help:"toggle verbose (debug) mode"` + Filter []string `arg:"-f,separate" help:"name of a filter that will be applied to text, can be specified multiple times"` } func errExit(err error) { @@ -34,18 +35,20 @@ func main() { slog.Debug("uptfs started") var configFilePath string + + var config config.Config var err error if args.ConfigFile != "" { configFilePath, err = filepath.Abs(args.ConfigFile) + config.LoadConfig(configFilePath) slog.Debug("config file path: " + configFilePath) } if err != nil { - errExit(err) + slog.Error(err.Error()) } - var config config.Config - config.LoadConfig(configFilePath) + config.Filters = append(config.Filters, args.Filter...) var inputStrings []string scanner := bufio.NewScanner(os.Stdin) -- cgit v1.2.3