cmd

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 16, 2025 License: AGPL-3.0 Imports: 24 Imported by: 0

Documentation

Overview

Modules can register custom hooks here that will plug into urfave *cli.App API. The hooks will be called in the same order as defined urfave's cli.

Index

Constants

View Source
const (
	PocketImporterID = "pocket-import"
)

Variables

View Source
var ConfigCmds = &cli.Command{
	Name: "config",
	Commands: []*cli.Command{
		cfgPrintCmd,
		cfgDebugCmd,
	},
}
View Source
var DebugInfoCmd = &cli.Command{
	Name:   "debug-info",
	Hidden: true,
	Action: func(_ context.Context, _ *cli.Command) error {
		build.DebugInfo()
		return nil
	},
}
View Source
var DetectCmd = &cli.Command{
	Name:    "detect",
	Aliases: []string{"det"},
	Usage:   "detect installed browsers",
	Action: func(ctx context.Context, cmd *cli.Command) error {
		red := color.New(color.FgRed).SprintFunc()
		green := color.New(color.FgGreen).SprintFunc()
		mods := modules.GetModules()
		fmt.Printf("\n detected browsers:\n\n")
		for _, mod := range mods {
			browser, isBrowser := mod.ModInfo().New().(modules.BrowserModule)
			if !isBrowser {
				log.Debugf("module <%s> is not a browser", mod.ModInfo().ID)
				continue
			}

			pm, isProf := browser.(profiles.ProfileManager)
			if !isProf {
				log.Debugf("module <%s> is not a profile manager", mod.ModInfo().ID)

				d, ok := browser.(modules.Detector)
				if ok {
					detected, err := d.Detect()
					if err != nil {
						return fmt.Errorf("detecting browser: %w", err)
					}
					for _, dbr := range detected {
						fmt.Printf(" %s %-10s \t %s\n", green(""), dbr.Flavour, dbr.BasePath)
					}

				} else {
					fmt.Printf(" %s %-10s\n", red(""), mod.ModInfo().ID)
				}

				continue
			}

			flavours := pm.ListFlavours()
			for _, f := range flavours {
				log.Debugf("considering flavour <%s> of <%s>", f.Flavour, mod.ModInfo().ID)
				if dir, err := f.ExpandBaseDir(); err != nil {
					log.Info("base directory not found", "path", f.BaseDir(), "flavour", f.Flavour)
					continue
				} else {
					fmt.Printf(" %s %-10s \t %s\n", green(""), f.Flavour, dir)
				}
			}
		}

		fmt.Println()
		return nil
	},
}
View Source
var ExportCmds = &cli.Command{
	Name:        "export",
	Usage:       "One-time export to other formats",
	Description: `The export command provides functionality to export bookmarks to other browser or application formats. `,
	Commands: []*cli.Command{
		exportNSHTMLCmd,
		exportPocketHTMLCmd,
		exportJSONCmd,
		exportRSSCmd,
	},
}
View Source
var ImportCmds = &cli.Command{
	Name:  "import",
	Usage: "one-time import from other programs",
	Description: `The import command provides subcommands to migrate bookmarks from various sources.
Use the specific import subcommands to perform migrations.`,
	Commands: []*cli.Command{
		importBukuDBCmd,
		importPocketCmd,
	},
}
View Source
var MainFlags = []cli.Flag{
	logging.DebugFlag,
	&cli.StringFlag{
		Name:        "config",
		Aliases:     []string{"c"},
		Value:       config.DefaultConfPath(),
		Usage:       "config `path`",
		DefaultText: utils.Shorten(config.DefaultConfPath()),
		Destination: &config.ConfigFileFlag,
	},

	&cli.StringFlag{
		Name:        "db",
		Value:       database.GetDBPath(),
		DefaultText: utils.Shorten(database.GetDBPath()),
		Usage:       "`path` where gosuki.db is stored",
		Destination: &config.DBPath,
		Sources:     cli.NewValueSourceChain(toml.TOML("database.path", altsrc.NewStringPtrSourcer(&config.ConfigFileFlag))),
	},
}
View Source
var ModuleCmds = &cli.Command{
	Name:    "modules",
	Aliases: []string{"m"},
	Usage:   "module commands",
	Commands: []*cli.Command{
		listModulesCmd,
	},
}
View Source
var ProfileCmds = &cli.Command{
	Name:    "profile",
	Aliases: []string{"p"},
	Usage:   "profile commands",
	Commands: []*cli.Command{
		listProfilesCmd,
		DetectCmd,
	},
}

Functions

func GlobalFlags

func GlobalFlags(modID string) []cli.Flag

GlobalFlags returns the registered global flags for a given registered module

func RegBeforeHook

func RegBeforeHook(modID string, hook Hook)

Register a module hook to be run in *cli.App.Before

func RegGlobalModFlag

func RegGlobalModFlag(modID string, flags ...cli.Flag)

RegGlobalModFlag registers global flags to pass on to the browser module

func RegisterModCommand

func RegisterModCommand(modID string, cmd *cli.Command)

func RegisteredModCommands

func RegisteredModCommands(modID string) modCmds

return list of registered commands for browser module

Types

type Hook

type Hook func(context.Context, *cli.Command) error

func BeforeHook

func BeforeHook(modID string) Hook

Return all registered Before hooks for module

Directories

Path Synopsis
Main command line entry point for gosuki
Main command line entry point for gosuki

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL