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:
+10
-23
@@ -10,8 +10,6 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
searchTag string
|
||||
|
||||
searchCmd = &cobra.Command{
|
||||
Use: "search [query]",
|
||||
Short: "Search notes by content or tags",
|
||||
@@ -20,7 +18,6 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
searchCmd.Flags().StringVarP(&searchTag, "tag", "t", "", "Search by tag")
|
||||
rootCmd.AddCommand(searchCmd)
|
||||
}
|
||||
|
||||
@@ -33,25 +30,15 @@ func searchNotes(cmd *cobra.Command, args []string) {
|
||||
|
||||
var results []string
|
||||
|
||||
// Search by tag if flag is provided
|
||||
if searchTag != "" {
|
||||
results, err = jd.SearchByTag(searchTag)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error searching by tag: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
} else {
|
||||
// Search by content
|
||||
if len(args) == 0 {
|
||||
fmt.Fprintf(os.Stderr, "Error: query required when not searching by tag\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
query := strings.Join(args, " ")
|
||||
results, err = jd.SearchContent(query)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error searching: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
if len(args) == 0 {
|
||||
fmt.Fprintf(os.Stderr, "Error: query required when not searching by tag\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
query := strings.Join(args, " ")
|
||||
results, err = jd.SearchContent(query)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error searching: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if len(results) == 0 {
|
||||
@@ -62,7 +49,7 @@ func searchNotes(cmd *cobra.Command, args []string) {
|
||||
fmt.Printf("Found %d match(es):\n\n", len(results))
|
||||
for _, path := range results {
|
||||
// Load note to get title
|
||||
note, err := engine.LoadNote(jd.Config.DepoPath, path, jd.Config.TagPrefix)
|
||||
note, err := engine.LoadNote(jd.Config.DepoPath, path)
|
||||
if err != nil {
|
||||
fmt.Printf(" %s\n", path)
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user