cmd

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2025 License: MIT Imports: 27 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Args []string
View Source
var DemonFlag bool

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

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.AutoSetCachePath()
	},
}

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

View Source
var StopDaemonFlag bool
View Source
var (

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

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

Functions

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(path string, reScanFile bool)

func ReScanUploadPath

func ReScanUploadPath()

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

func RegisterBroadcast added in v1.0.0

func RegisterBroadcast(name string) chan string

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

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 TODO:退出时清理临时文件的函数

func SetStorePath added in v1.0.0

func SetStorePath(args []string)

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

func ShowQRCode added in v1.0.0

func ShowQRCode()

Types

This section is empty.

Jump to

Keyboard shortcuts

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