utils

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConfigInstance = Config{}

Functions

func CloseGormDB

func CloseGormDB() error

func EnsureDir

func EnsureDir(path string) error

func FileExists

func FileExists(path string) bool

func GetDefaultConfig

func GetDefaultConfig() *models.AppConfig

默认配置

func GetExeDir

func GetExeDir() string

func GetGitRoot added in v0.0.9

func GetGitRoot() (string, error)

func GetGormDB

func GetGormDB() (*gorm.DB, error)

func GetProjectRoot

func GetProjectRoot() (string, error)

func HideWindow added in v0.0.9

func HideWindow(cmd *exec.Cmd) *exec.Cmd

HideWindow 在非 Windows 平台为 no-op——控制台窗口闪烁是 Windows GUI 子系统 特有的问题,Unix 平台无此概念。保留同名函数使调用方无需按平台分支。

func InitAppDirs

func InitAppDirs() error

func InitDataDirs added in v0.0.3

func InitDataDirs() error

func IsPathWithin added in v0.0.9

func IsPathWithin(child, parent string) bool

IsPathWithin reports whether `child` is the same as or inside `parent`. It uses filepath.Rel to correctly reject prefix-lookalikes (e.g. parent="/a/repo", child="/a/repo-evil" → false), which a naive strings.HasPrefix check would wrongly accept.

Both paths are cleaned first. Symlinks are NOT resolved — callers that need symlink-safe checks should filepath.EvalSymlinks first.

func MigratePathsIfNeeded added in v0.0.3

func MigratePathsIfNeeded()

func OutputJSON

func OutputJSON(v any)

func OutputJSONL

func OutputJSONL(items any)

Types

type Config

type Config struct {
	HomeDir      string
	AppSeriesDir string
	AppDir       string
	ConfigDir    string
	ConfigPath   string
	DbDir        string
	DbPath       string
	LogDir       string
	LogPath      string
	ReposDir     string
	WikiDir      string
}

func (*Config) ApplyConfig

func (c *Config) ApplyConfig(appConfig *models.AppConfig)

func (*Config) GetAppDir

func (c *Config) GetAppDir() string

func (*Config) GetAppSeriesDir

func (c *Config) GetAppSeriesDir() string

func (*Config) GetConfigDir

func (c *Config) GetConfigDir() string

func (*Config) GetConfigPath

func (c *Config) GetConfigPath() string

func (*Config) GetDbDir

func (c *Config) GetDbDir() string

func (*Config) GetDbPath

func (c *Config) GetDbPath() string

func (*Config) GetHomeDir

func (c *Config) GetHomeDir() string

func (*Config) GetLocalWikiDir added in v0.0.8

func (c *Config) GetLocalWikiDir() string

func (*Config) GetLogDir

func (c *Config) GetLogDir() string

func (*Config) GetLogPath

func (c *Config) GetLogPath() string

func (*Config) GetReposDir

func (c *Config) GetReposDir() string

func (*Config) GetReposDirFromConfig

func (c *Config) GetReposDirFromConfig(appConfig *models.AppConfig) string

func (*Config) GetWikiDir

func (c *Config) GetWikiDir() string

func (*Config) LoadConfig

func (c *Config) LoadConfig() *models.AppConfig

func (*Config) SaveConfig

func (c *Config) SaveConfig(config *models.AppConfig) error

type OutputFormat

type OutputFormat string
const (
	FormatTable OutputFormat = "table"
	FormatJSON  OutputFormat = "json"
	FormatJSONL OutputFormat = "jsonl"
)

func ParseFormat

func ParseFormat(s string) OutputFormat

Jump to

Keyboard shortcuts

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