1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
/*
Copyright © 2025 NAME HERE <EMAIL ADDRESS>
*/
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)")
}
|