Add multi-depository support with global config
- Implement global CLI config at ~/.config/jade/config.yml - Add jade depo commands (add, list, remove, set-default) - Support depository short names and context-aware detection - Remove tag_prefix config, hardcode + syntax for consistency - Update depository resolution: flag -> context -> default - Auto-initialize .jade/ directory structure when adding depos - Update documentation with new multi-depository workflow
This commit is contained in:
+16
-10
@@ -17,21 +17,27 @@ var (
|
||||
)
|
||||
|
||||
var (
|
||||
cfgPath string
|
||||
depoPath string
|
||||
depoInput string
|
||||
)
|
||||
|
||||
func init() {
|
||||
cobra.OnInitialize(func() {
|
||||
if _, err := engine.Init(cfgPath, depoPath); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error initializing configuration: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
})
|
||||
cobra.OnInitialize(initializeIfNeeded)
|
||||
rootCmd.PersistentFlags().StringVar(&depoInput, "depo", "", "Depository name or path")
|
||||
}
|
||||
|
||||
rootCmd.PersistentFlags().StringVar(&cfgPath, "config", "", "Configuration file path. Default <depo>/.jade/config.yml")
|
||||
rootCmd.PersistentFlags().StringVar(&depoPath, "depo", "", "Depository path. Default $HOME/jade-depository")
|
||||
// initializeIfNeeded initializes the depository only for commands that need it
|
||||
func initializeIfNeeded() {
|
||||
// Skip initialization for depo management commands
|
||||
cmd := os.Args
|
||||
if len(cmd) > 1 && cmd[1] == "depo" {
|
||||
return
|
||||
}
|
||||
|
||||
// Initialize for all other commands
|
||||
if _, err := engine.Init(depoInput); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error initializing configuration: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func openDepository(cmd *cobra.Command, args []string) {
|
||||
|
||||
Reference in New Issue
Block a user