修改git过滤文件

This commit is contained in:
zyj
2026-03-04 10:14:12 +08:00
parent a9f9330744
commit 89d64cb117
12 changed files with 570 additions and 1 deletions

View File

@@ -0,0 +1,80 @@
package commands
import (
"fmt"
"os"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/user/devpack/pkg/version"
)
var (
cfgFile string
verbose bool
quiet bool
logLevel string
noColor bool
)
// rootCmd represents the base command
var rootCmd = &cobra.Command{
Use: "devpack",
Short: "DevPack - 开发环境打包迁移工具",
Long: `DevPack 是一个开发环境打包迁移工具。
它能够扫描、捕获并打包你的完整开发环境,
在另一台同系统的电脑上一键还原。
让开发环境像 U 盘一样即插即用。`,
Version: version.GetVersionString(),
}
// Execute adds all child commands to the root command and sets flags appropriately.
func Execute() error {
return rootCmd.Execute()
}
func init() {
cobra.OnInitialize(initConfig)
// Global flags
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "配置文件路径 (默认: ~/.devpack/config.yaml)")
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "详细输出")
rootCmd.PersistentFlags().BoolVarP(&quiet, "quiet", "q", false, "静默模式")
rootCmd.PersistentFlags().StringVar(&logLevel, "log-level", "info", "日志级别 (trace|debug|info|warn|error)")
rootCmd.PersistentFlags().BoolVar(&noColor, "no-color", false, "禁用彩色输出")
// Add subcommands
rootCmd.AddCommand(newInitCmd())
rootCmd.AddCommand(newScanCmd())
rootCmd.AddCommand(newCaptureCmd())
rootCmd.AddCommand(newRestoreCmd())
rootCmd.AddCommand(newExportCmd())
rootCmd.AddCommand(newImportCmd())
rootCmd.AddCommand(newListCmd())
rootCmd.AddCommand(newDiffCmd())
rootCmd.AddCommand(newProfileCmd())
rootCmd.AddCommand(newVersionCmd())
}
func initConfig() {
if cfgFile != "" {
viper.SetConfigFile(cfgFile)
} else {
home, err := os.UserHomeDir()
if err != nil {
fmt.Fprintln(os.Stderr, "Error:", err)
os.Exit(1)
}
viper.AddConfigPath(home + "/.devpack")
viper.SetConfigName("config")
viper.SetConfigType("yaml")
}
viper.SetEnvPrefix("DEVPACK")
viper.AutomaticEnv()
// Read config file (ignore error if not found)
_ = viper.ReadInConfig()
}