cmd

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2025 License: MIT Imports: 29 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DemonFlag      bool
	StopDaemonFlag bool
)

DemonFlag 正确地实装,需要理解守护进程的概念 需要去 cmd/init_flags.go 设置flag

View Source
var Args []string
View Source
var RootCmd = &cobra.Command{
	Use:     locale.GetString("comigo_use"),
	Short:   locale.GetString("short_description"),
	Example: locale.GetString("comigo_example"),
	Version: config.GetVersion(),
	Long:    locale.GetString("long_description"),

	Run: func(cmd *cobra.Command, args []string) {
		Args = args

		config.SetByExecutableFilename()

		config.AutoSetCacheDir()
	},
}

RootCmd 没有任何子命令的情况下时的基本命令

View Source
var (

	// SystemBroadcast 等于 RegisterBroadcast("system") 返回的通道。
	SystemBroadcast chan string
)

broadcastRegistry 保存所有注册的系统广播通道,key 为自定义名称。 通过 map 的方式可以在不同包中动态注册并复用所需的广播通道。

Functions

func CreateStoreUrls added in v1.1.0

func CreateStoreUrls(args []string)

CreateStoreUrls 添加默认扫描路径 args[1:]是用户指定的扫描路径

func Execute

func Execute()

Execute 将所有子命令添加到根命令并适当设置标志。 由 main.main() 调用的。 rootCmd 只需要执行一次。

func GetBroadcast added in v1.0.0

func GetBroadcast(name string) (chan string, bool)

GetBroadcast 返回指定名称的广播通道(只读锁)。

func InitFlags added in v0.9.12

func InitFlags()

func LoadConfigFile added in v1.0.0

func LoadConfigFile()

LoadConfigFile 读取顺序:RAM(代码当中设定的默认值)+命令行参数 -> HomeDirectory -> ProgramDirectory -> WorkingDirectory

func ReScanPath

func ReScanPath(storeUrl string, reScanFile bool)

ReScanPath 重新扫描目录,因为需要设置下载路径,gin 初始化后才能执行

func RegisterBroadcast added in v1.0.0

func RegisterBroadcast(name string) chan string

RegisterBroadcast 创建或返回一个已存在的广播通道。 不同模块可以调用此方法注册/获取自己的通道,实现解耦。

func ReloadConfigHandler added in v1.1.0

func ReloadConfigHandler(e fsnotify.Event)

监听配置文件变更 优雅地重启或停止 https://learnku.com/docs/gin-gonic/1.7/examples-graceful-restart-or-stop/11376

func ScanStore added in v1.0.0

func ScanStore(args []string)

ScanStore 解析命令,扫描文件,设置书库等

func SetDaemon added in v1.0.0

func SetDaemon()

SetDaemon 设置守护进程, To terminate the daemon use: kill `cat comigo.pid` 该函数会在Unix系统上将当前进程转化为守护进程,并在后台运行。 如果当前系统不是Unix系统,或者没有指定启动或停止守护进程的参数,则直接返回。 https://github.com/sevlyar/go-daemon https://github.com/sevlyar/go-daemon/blob/v0.1.6/examples/cmd/gd-simple/simple.go go run main.go --start go run main.go --stop

func SetShutdownHandler

func SetShutdownHandler()

SetShutdownHandler 退出时清理临时文件的函数

func ShowQRCode added in v1.0.0

func ShowQRCode()

func ShowQRCodeTailscale added in v1.1.0

func ShowQRCodeTailscale(ctx context.Context)

ShowQRCodeTailscale 打印 Tailscale 访问地址的二维码

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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