summaryrefslogtreecommitdiff
path: root/cmd/root.go
blob: e93a4e7ab27f3a6377ea20fc726f61e97a95fad6 (plain)
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
/*
Copyright © 2025 Francesco Orlando scrotadamus@insiberia.net
*/
package cmd

import (
	"os"

	"github.com/scrotadamus/ghligh/cmd/tag"
	"github.com/scrotadamus/ghligh/go-poppler"
	"github.com/spf13/cobra"
)

var warnings bool

var rootCmd = &cobra.Command{
	Use:   "ghligh",
	Short: "pdf highlights swiss knife",
	Long:  `ghligh can be used to manipulate pdf files in various ways.`,

	PersistentPreRunE: func(cmd *cobra.Command, args []string) error {

		if !warnings {
			poppler.DisablePopplerWarnings()
		}

		return nil
	},

	Run: func(cmd *cobra.Command, args []string) {
		cmd.Help()
		return
	},
}

// Execute adds all child commands to the root command and sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute() {
	err := rootCmd.Execute()
	if err != nil {
		os.Exit(1)
	}
}

func init() {
	//rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
	rootCmd.AddCommand(tag.TagCmd)
	rootCmd.PersistentFlags().BoolVar(&warnings, "warnings", false, "show poppler warnings")
}