cmd

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2025 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Overview

commands related to modules

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 DebugCmd = &cli.Command{
	Name:  "debug",
	Usage: "debug",
	Action: func(ctx context.Context, cmd *cli.Command) error {
		var err error

		mt := marktab.MarkTab{}
		err = mt.LoadMarktabs()
		if err != nil {
			return err
		}

		pretty.Print(mt)
		return err
	},
}
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.Warn("expanding base directory", "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 ImportCmds = &cli.Command{
	Name:  "import",
	Usage: "one-time import bookmarks from other programs",
	Commands: []*cli.Command{
		importBukuDBCmd,
		importPocketCmd,
	},
}
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, flag 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