From 17fb6add26291b31f7020e3551a7c8487130a747 Mon Sep 17 00:00:00 2001 From: "F.O." Date: Sun, 16 Feb 2025 17:56:08 +0100 Subject: genesi --- cmd/tag/tag.go | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 cmd/tag/tag.go (limited to 'cmd/tag/tag.go') diff --git a/cmd/tag/tag.go b/cmd/tag/tag.go new file mode 100644 index 0000000..30e41c8 --- /dev/null +++ b/cmd/tag/tag.go @@ -0,0 +1,63 @@ +/* +Copyright © 2025 NAME HERE + +*/ +package tag + +import ( + "regexp" + "github.com/spf13/cobra" +) + + +var tags []string + +var regex, exact string + +func formatRegex(r string, boundaries string) string { + //return `\b` + r + `\b` + return boundaries + r + boundaries +} + +func regexSlice(regex string, slice []string) []string { + if regex == "" { + return slice + } + + var newSlice []string + re, err := regexp.Compile(regex) + if err != nil { + panic(err) + } + for _, s := range(slice){ + if re.MatchString(s){ + newSlice = append(newSlice, s) + } + } + + return newSlice +} + +// tagCmd represents the tag command +var TagCmd = &cobra.Command{ + Use: "tag", + Short: "manage pdf tags", + Long: `a tag is a string you can attach to a pdf +.`, +} + +func init() { + //rootCmd.AddCommand(tagCmd) + + // Here you will define your flags and configuration settings. + + // Cobra supports Persistent Flags which will work for this command + // and all subcommands, e.g.: + // tagCmd.PersistentFlags().String("foo", "", "A help for foo") + + // Cobra supports local flags which will only run when this command + // is called directly, e.g.: + // tagCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") + // TODO add to "add" command + // tagCmd.Flags().StringArrayVarP(&tags, "tag", "t", []string{}, "Tag da associare ai file (può essere usato più volte)") +} -- cgit v1.2.3