### Install go-ansisgr Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/ktr0731/go-ansisgr/README.md Use 'go get' to install the go-ansisgr library. Note: The example shows go-fuzzyfinder, which might be a typo in the original README. ```bash go get github.com/ktr0731/go-fuzzyfinder ``` -------------------------------- ### Install frontmatter Go Library Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/adrg/frontmatter/README.md Use 'go get' to install the frontmatter library. This command fetches and installs the specified package. ```bash go get github.com/adrg/frontmatter ``` -------------------------------- ### Install uniseg Package Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/rivo/uniseg/README.md Use go get to install the uniseg package. ```bash go get github.com/rivo/uniseg ``` -------------------------------- ### Install go-fuzzyfinder Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/ktr0731/go-fuzzyfinder/README.md Install the go-fuzzyfinder library using the go get command. ```bash $ go get github.com/ktr0731/go-fuzzyfinder ``` -------------------------------- ### Install go-colorful Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/lucasb-eyer/go-colorful/README.md Install the go-colorful library using the go get command. This command fetches and installs the package and its dependencies. ```bash go get github.com/lucasb-eyer/go-colorful ``` -------------------------------- ### Install Cobra Library Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/spf13/cobra/README.md Install the latest version of the Cobra library using go get. ```go go get -u github.com/spf13/cobra@latest ``` -------------------------------- ### Run Keyboard Example Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/nsf/termbox-go/README.md This command demonstrates how to run the keyboard input example provided within the termbox-go library. ```bash go run _demos/keyboard.go ``` -------------------------------- ### Install TOML Parser Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/BurntSushi/toml/README.md Install the BurntSushi/toml package using go get. ```bash go get github.com/BurntSushi/toml ``` -------------------------------- ### Verify Installation Source: https://github.com/yakitrak/notesmd-cli/blob/main/MIGRATION.md Check the installed version and verify the default vault setting. ```bash # Check version notesmd-cli --version # Verify your default vault notesmd-cli print-default ``` -------------------------------- ### Install notesmd-cli (Windows Scoop) Source: https://github.com/yakitrak/notesmd-cli/blob/main/MIGRATION.md Add the necessary bucket and install notesmd-cli using Scoop on Windows. ```bash scoop bucket add scoop-yakitrak https://github.com/yakitrak/scoop-yakitrak.git scoop install notesmd-cli ``` -------------------------------- ### FindMulti Example with Preview Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/ktr0731/go-fuzzyfinder/README.md Demonstrates using FindMulti to select multiple items with a preview window. The preview displays detailed information about the selected item. ```go type Track struct { Name string AlbumName string Artist string } var tracks = []Track{ {"foo", "album1", "artist1"}, {"bar", "album1", "artist1"}, {"foo", "album2", "artist1"}, {"baz", "album2", "artist2"}, {"baz", "album3", "artist2"}, } func main() { idx, err := fuzzyfinder.FindMulti( tracks, func(i int) string { return tracks[i].Name }, fuzzyfinder.WithPreviewWindow(func(i, w, h int) string { if i == -1 { return "" } return fmt.Sprintf("Track: %s (%s)\nAlbum: %s", tracks[i].Name, tracks[i].Artist, tracks[i].AlbumName) })) if err != nil { log.Fatal(err) } fmt.Printf("selected: %v\n", idx) } ``` -------------------------------- ### Build NotesMD CLI from Source Source: https://github.com/yakitrak/notesmd-cli/blob/main/README.md Build the NotesMD CLI from source using Go and install it globally. ```bash git clone https://github.com/yakitrak/notesmd-cli.git cd notesmd-cli go build -o notesmd-cli . sudo install -m 755 notesmd-cli /usr/local/bin/ ``` -------------------------------- ### Install NotesMD CLI from AUR Source: https://github.com/yakitrak/notesmd-cli/blob/main/README.md Install the NotesMD CLI from the Arch User Repository (AUR) using yay. ```bash yay -S notesmd-cli-bin ``` -------------------------------- ### Install NotesMD CLI with Scoop Source: https://github.com/yakitrak/notesmd-cli/blob/main/README.md Install the NotesMD CLI using Scoop on Windows. ```powershell scoop install notesmd-cli ``` -------------------------------- ### Install notesmd-cli (Arch Linux AUR) Source: https://github.com/yakitrak/notesmd-cli/blob/main/MIGRATION.md Install notesmd-cli from the Arch Linux AUR using yay or paru. ```bash # Using yay yay -S notesmd-cli-bin # Using paru paru -S notesmd-cli-bin ``` -------------------------------- ### Install Cobra CLI Generator Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/spf13/cobra/README.md Install the cobra-cli command-line program for generating Cobra application scaffolding. ```go go install github.com/spf13/cobra-cli@latest ``` -------------------------------- ### Install NotesMD CLI with Homebrew Source: https://github.com/yakitrak/notesmd-cli/blob/main/README.md Install the NotesMD CLI using Homebrew on Mac and Linux. ```bash brew install yakitrak/yakitrak/notesmd-cli ``` -------------------------------- ### Get NotesMD CLI Help Source: https://github.com/yakitrak/notesmd-cli/blob/main/README.md Display all available commands and instructions for the NotesMD CLI. ```bash notesmd-cli --help ``` -------------------------------- ### Go tcell Demo Application Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/gdamore/tcell/v2/TUTORIAL.md This is a complete example of a tcell application. It initializes the screen, defines functions for drawing boxes and text, and includes an event loop to handle user input (keyboard and mouse). It also demonstrates screen clearing and resizing. ```go package main import ( "fmt" "log" "github.com/gdamore/tcell/v2" ) func drawText(s tcell.Screen, x1, y1, x2, y2 int, style tcell.Style, text string) { row := y1 col := x1 for _, r := range []rune(text) { s.SetContent(col, row, r, nil, style) col++ if col >= x2 { row++ col = x1 } if row > y2 { break } } } func drawBox(s tcell.Screen, x1, y1, x2, y2 int, style tcell.Style, text string) { if y2 < y1 { y1, y2 = y2, y1 } if x2 < x1 { x1, x2 = x2, x1 } // Fill background for row := y1; row <= y2; row++ { for col := x1; col <= x2; col++ { s.SetContent(col, row, ' ', nil, style) } } // Draw borders for col := x1; col <= x2; col++ { s.SetContent(col, y1, tcell.RuneHLine, nil, style) s.SetContent(col, y2, tcell.RuneHLine, nil, style) } for row := y1 + 1; row < y2; row++ { s.SetContent(x1, row, tcell.RuneVLine, nil, style) s.SetContent(x2, row, tcell.RuneVLine, nil, style) } // Only draw corners if necessary if y1 != y2 && x1 != x2 { s.SetContent(x1, y1, tcell.RuneULCorner, nil, style) s.SetContent(x2, y1, tcell.RuneURCorner, nil, style) s.SetContent(x1, y2, tcell.RuneLLCorner, nil, style) s.SetContent(x2, y2, tcell.RuneLRCorner, nil, style) } drawText(s, x1+1, y1+1, x2-1, y2-1, style, text) } func main() { defStyle := tcell.StyleDefault.Background(tcell.ColorReset).Foreground(tcell.ColorReset) boxStyle := tcell.StyleDefault.Foreground(tcell.ColorWhite).Background(tcell.ColorPurple) // Initialize screen s, err := tcell.NewScreen() if err != nil { log.Fatalf("%+v", err) } if err := s.Init(); err != nil { log.Fatalf("%+v", err) } s.SetStyle(defStyle) s.EnableMouse() s.EnablePaste() s.Clear() // Draw initial boxes drawBox(s, 1, 1, 42, 7, boxStyle, "Click and drag to draw a box") drawBox(s, 5, 9, 32, 14, boxStyle, "Press C to reset") quit := func() { // You have to catch panics in a defer, clean up, // and re-raise them - otherwise your application can // die without leaving any diagnostic trace. maybePanic := recover() s.Fini() if maybePanic != nil { panic(maybePanic) } } defer quit() // Here's how to get the screen size when you need it. // xmax, ymax := s.Size() // Here's an example of how to inject a keystroke where it will // be picked up by the next PollEvent call. Note that the // queue is LIFO, it has a limited length, and PostEvent() can // return an error. // s.PostEvent(tcell.NewEventKey(tcell.KeyRune, rune('a'), 0)) // Event loop ox, oy := -1, -1 for { // Update screen s.Show() // Poll event ev := s.PollEvent() // Process event switch ev := ev.(type) { case *tcell.EventResize: s.Sync() case *tcell.EventKey: if ev.Key() == tcell.KeyEscape || ev.Key() == tcell.KeyCtrlC { return } else if ev.Key() == tcell.KeyCtrlL { s.Sync() } else if ev.Rune() == 'C' || ev.Rune() == 'c' { s.Clear() } case *tcell.EventMouse: x, y := ev.Position() switch ev.Buttons() { case tcell.Button1, tcell.Button2: if ox < 0 { ox, oy = x, y // record location when click started } case tcell.ButtonNone: if ox >= 0 { label := fmt.Sprintf("%d,%d to %d,%d", ox, oy, x, y) drawBox(s, ox, oy, x, y, boxStyle, label) ox, oy = -1, -1 } } } } } ``` -------------------------------- ### Create Note and Open in Obsidian Source: https://github.com/yakitrak/notesmd-cli/blob/main/README.md Creates a new note with content and immediately opens it in Obsidian. Useful for creating and starting to work on a note simultaneously. ```bash notesmd-cli create "{note-name}" --content "abcde" --open ``` -------------------------------- ### Install TOML Validator Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/BurntSushi/toml/README.md Install and use the tomlv command-line tool for validating TOML files. ```bash go get github.com/BurntSushi/toml/cmd/tomlv tomlv some-toml-file.toml ``` -------------------------------- ### Install notesmd-cli (Mac/Linux Homebrew) Source: https://github.com/yakitrak/notesmd-cli/blob/main/MIGRATION.md Tap the required repository and install notesmd-cli using Homebrew on macOS or Linux. ```bash brew tap yakitrak/yakitrak brew install yakitrak/yakitrak/notesmd-cli ``` -------------------------------- ### Generate Custom Soft Palettes in Go Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/lucasb-eyer/go-colorful/README.md Demonstrates using SoftPaletteEx to generate custom palettes with specific color constraints. Includes an example for generating brownish colors with adjustable iteration count and sample settings. ```go func isbrowny(l, a, b float64) bool { h, c, L := colorful.LabToHcl(l, a, b) return 10.0 < h && h < 50.0 && 0.1 < c && c < 0.5 && L < 0.5 } // Since the above function is pretty restrictive, we set ManySamples to true. brownies := colorful.SoftPaletteEx(10, colorful.SoftPaletteSettings{isbrowny, 50, true}) ``` -------------------------------- ### Install and Update Termbox-Go Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/nsf/termbox-go/README.md Use this command to install or update the termbox-go package in your Go project. ```bash go get -u github.com/nsf/termbox-go ``` -------------------------------- ### Register an Obsidian Vault Source: https://github.com/yakitrak/notesmd-cli/blob/main/README.md Add a directory as an Obsidian vault. This is useful for headless setups or when Obsidian is not installed. The command creates the necessary configuration file if it doesn't exist. ```bash # Register a vault notesmd-cli add-vault /path/to/vault # Register and set as default notesmd-cli add-vault /path/to/vault --set-default ``` -------------------------------- ### Check if Started by Explorer Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/inconshreveable/mousetrap/README.md This function returns true if the process was started by double-clicking the executable in Windows Explorer. It is useful for providing better user experiences for users unfamiliar with the command line. ```Go func StartedByExplorer() (bool) ``` -------------------------------- ### Uninstall obsidian-cli (Manual Installation) Source: https://github.com/yakitrak/notesmd-cli/blob/main/MIGRATION.md Steps to remove a manually installed obsidian-cli binary. First find its location, then remove it. ```bash # Find where it's installed which obsidian-cli # Remove it (common locations) sudo rm /usr/local/bin/obsidian-cli # or rm ~/bin/obsidian-cli ``` -------------------------------- ### Update Shell Alias Example Source: https://github.com/yakitrak/notesmd-cli/blob/main/MIGRATION.md Example of how to update a shell alias in .zshrc or .bashrc to point to the new notesmd-cli. ```bash # Example: Update a shell alias in ~/.zshrc or ~/.bashrc # Old: alias obs='obsidian-cli' # New: alias obs='notesmd-cli' ``` -------------------------------- ### Create or Open Daily Note Source: https://github.com/yakitrak/notesmd-cli/blob/main/README.md Creates a new daily note or opens an existing one in your default editor. Useful for quickly starting your daily journaling. ```bash notesmd-cli daily --editor ``` -------------------------------- ### Import go-colorful Package Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/lucasb-eyer/go-colorful/README.md Import the go-colorful package into your Go project to start using its color manipulation functionalities. ```go import "github.com/lucasb-eyer/go-colorful" ``` -------------------------------- ### Copy wasm_exec.js Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/gdamore/tcell/v2/README-wasm.md Copy the wasm_exec.js file from your Go installation to the project directory. ```sh cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" ./ ``` -------------------------------- ### Color Distance Comparison Output Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/lucasb-eyer/go-colorful/README.md Example output from the color distance comparison program, illustrating the numerical results of different distance metrics. ```bash $ go run colordist.go DistanceRgb: c1: 0.3803921568627451 and c2: 0.3858713931171159 DistanceLab: c1: 0.32048458312798056 and c2: 0.24397151758565272 DistanceLuv: c1: 0.5134369614199698 and c2: 0.2568692839860636 DistanceCIE76: c1: 0.32048458312798056 and c2: 0.24397151758565272 DistanceCIE94: c1: 0.19799168128511324 and c2: 0.12207136371167401 DistanceCIEDE2000: c1: 0.17274551120971166 and c2: 0.10665210031428465 ``` -------------------------------- ### Set Default Vault Source: https://github.com/yakitrak/notesmd-cli/blob/main/MIGRATION.md Use this command to set your default vault if you are starting fresh. ```bash notesmd-cli set-default "{vault-name}" ``` -------------------------------- ### Add NotesMD CLI Scoop Bucket Source: https://github.com/yakitrak/notesmd-cli/blob/main/README.md Add the necessary Scoop bucket for installing the NotesMD CLI on Windows. ```powershell scoop bucket add scoop-yakitrak https://github.com/yakitrak/scoop-yakitrak.git ``` -------------------------------- ### Integrate go-ansisgr with gdamore/tcell Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/ktr0731/go-ansisgr/README.md An example demonstrating how to use go-ansisgr to parse ANSI escape sequences and render them using the gdamore/tcell library for rich terminal UIs. ```go package main import ( "log" "time" "github.com/gdamore/tcell/v2" "github.com/ktr0731/go-ansisgr" ) func main() { screen, err := tcell.NewScreen() if err != nil { log.Fatal(err) } defer screen.Fini() if err := screen.Init(); err != nil { log.Fatal(err) } in := "\x1b[38;2;100;200;200mhello, \x1b[0;1;30;48;5;245mworld!" iter := ansisgr.NewIterator(in) for i := 0; ; i++ { r, rstyle, ok := iter.Next() if !ok { break } style := tcell.StyleDefault if color, ok := rstyle.Foreground(); ok { switch color.Mode() { case ansisgr.Mode16: style = style.Foreground(tcell.PaletteColor(color.Value() - 30)) case ansisgr.Mode256: style = style.Foreground(tcell.PaletteColor(color.Value())) case ansisgr.ModeRGB: r, g, b := color.RGB() style = style.Foreground(tcell.NewRGBColor(int32(r), int32(g), int32(b))) } } if color, valid := rstyle.Background(); valid { switch color.Mode() { case ansisgr.Mode16: style = style.Background(tcell.PaletteColor(color.Value() - 40)) case ansisgr.Mode256: style = style.Background(tcell.PaletteColor(color.Value())) case ansisgr.ModeRGB: r, g, b := color.RGB() style = style.Background(tcell.NewRGBColor(int32(r), int32(g), int32(b))) } } style = style. Bold(rstyle.Bold()). Dim(rstyle.Dim()). Italic(rstyle.Italic()). Underline(rstyle.Underline()). Blink(rstyle.Blink()). Reverse(rstyle.Reverse()). StrikeThrough(rstyle.Strikethrough()) screen.SetContent(i, 0, r, nil, style) } screen.Show() time.Sleep(3 * time.Second) } ``` -------------------------------- ### Uninstall obsidian-cli (Windows Scoop) Source: https://github.com/yakitrak/notesmd-cli/blob/main/MIGRATION.md Use this command to uninstall the old version if installed via Scoop on Windows. ```bash scoop uninstall obsidian-cli ``` -------------------------------- ### Create Note, Add Content, and Open in Editor Source: https://github.com/yakitrak/notesmd-cli/blob/main/README.md Creates a note with content and opens it in your default editor. Combines note creation with immediate editing. ```bash notesmd-cli create "{note-name}" --content "abcde" --open --editor ``` -------------------------------- ### Using Custom White References in Go Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/lucasb-eyer/go-colorful/README.md Shows how to create and use colors with custom white references, such as D50, using LabWhiteRef. ```go c := colorful.LabWhiteRef(0.507850, 0.040585,-0.370945, colorful.D50) l, a, b := c.LabWhiteRef(colorful.D50) ``` -------------------------------- ### Run All Tests with Make Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/spf13/cobra/CONTRIBUTING.md Execute all tests using the make utility. This is a convenient way to run the test suite. ```shell make test ``` -------------------------------- ### Create Colors in Different Spaces Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/lucasb-eyer/go-colorful/README.md Demonstrates creating a color object from various color spaces including RGB, Hex, HSV, XYZ, XYY, Lab, Luv, and HCL. ```go c := colorful.Color{0.313725, 0.478431, 0.721569} c, err := colorful.Hex("#517AB8") if err != nil { log.Fatal(err) } c = colorful.Hsv(216.0, 0.56, 0.722) c = colorful.Xyz(0.189165, 0.190837, 0.480248) c = colorful.Xyy(0.219895, 0.221839, 0.190837) c = colorful.Lab(0.507850, 0.040585,-0.370945) c = colorful.Luv(0.507849,-0.194172,-0.567924) c = colorful.Hcl(276.2440, 0.373160, 0.507849) fmt.Printf("RGB values: %v, %v, %v", c.R, c.G, c.B) ``` -------------------------------- ### Create Note with Content Source: https://github.com/yakitrak/notesmd-cli/blob/main/README.md Creates a new note with the specified name and immediately populates it with content. Intermediate directories are created automatically. ```bash notesmd-cli create "{note-name}" --content "abcde" ``` -------------------------------- ### Migrate Configuration (Linux/Mac) Source: https://github.com/yakitrak/notesmd-cli/blob/main/MIGRATION.md Copy the old preferences.json to the new config directory for Linux and macOS. Creates the new directory if it doesn't exist. ```bash # Create new config directory mkdir -p ~/.config/notesmd-cli # Copy your old config cp ~/.config/obsidian-cli/preferences.json ~/.config/notesmd-cli/preferences.json ``` -------------------------------- ### Add Content and Open Daily Note Source: https://github.com/yakitrak/notesmd-cli/blob/main/README.md Appends content to your daily note and then opens it in your default editor. Combines content addition with immediate review. ```bash notesmd-cli daily --content "abcde" --editor ``` -------------------------------- ### Clone Fork and Configure Remotes Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/adrg/frontmatter/CONTRIBUTING.md Clone your fork of the repository and set up the upstream remote to track the original project. This is the first step in preparing your local environment for contributions. ```bash git clone https://github.com./ cd git remote add upstream https://github.com./ ``` -------------------------------- ### Format Code with Make Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/spf13/cobra/CONTRIBUTING.md Ensure new code adheres to project formatting standards. Run this command before committing changes. ```shell make all ``` -------------------------------- ### Migrate Configuration (Windows) Source: https://github.com/yakitrak/notesmd-cli/blob/main/MIGRATION.md Copy the old preferences.json to the new config directory for Windows. Creates the new directory if it doesn't exist. ```powershell # Create new config directory New-Item -ItemType Directory -Force -Path "$env:APPDATA\notesmd-cli" # Copy your old config Copy-Item "$env:APPDATA\obsidian-cli\preferences.json" "$env:APPDATA\notesmd-cli\preferences.json" ``` -------------------------------- ### Uninstall obsidian-cli (Mac/Linux Homebrew) Source: https://github.com/yakitrak/notesmd-cli/blob/main/MIGRATION.md Use this command to uninstall the old version if installed via Homebrew on macOS or Linux. ```bash brew uninstall obsidian-cli ``` -------------------------------- ### Fast Linear RGB Conversion in Go Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/lucasb-eyer/go-colorful/README.md Illustrates how to quickly convert an RGB color to its linear RGB representation using the FastLinearRgb method. ```go r, g, b := colorful.Hex("#FF0000").FastLinearRgb() ``` -------------------------------- ### Get Integer Value from FlagSet Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/spf13/pflag/README.md Retrieve the integer value of a specific flag from a FlagSet using GetInt(). Ensure the flag exists and is of the correct type. ```go i, err := flagset.GetInt("flagname") ``` -------------------------------- ### Migrate Configuration (Mac Alternative) Source: https://github.com/yakitrak/notesmd-cli/blob/main/MIGRATION.md Copy the old preferences.json to the new config directory if it was located in the home directory on macOS. ```bash # Create new config directory mkdir -p ~/.notesmd-cli # Copy your old config cp ~/.obsidian-cli/preferences.json ~/.notesmd-cli/preferences.json ``` -------------------------------- ### Generate Random Colors in Go Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/lucasb-eyer/go-colorful/README.md Demonstrates generating random colors with specific hues, saturation, and lightness using HCL space. Also shows how to generate random warm, happy, dark, and light colors. ```go random_blue := colorful.Hcl(180.0+rand.Float64()*50.0, 0.2+rand.Float64()*0.8, 0.3+rand.Float64()*0.7) random_dark := colorful.Hcl(rand.Float64()*360.0, rand.Float64(), rand.Float64()*0.4) random_light := colorful.Hcl(rand.Float64()*360.0, rand.Float64(), 0.6+rand.Float64()*0.4) ``` -------------------------------- ### Search Notes and Open in Editor Source: https://github.com/yakitrak/notesmd-cli/blob/main/README.md Searches for notes and opens the selected note in your default editor. Useful for quick edits after searching. ```bash notesmd-cli search --editor ``` -------------------------------- ### Update Local Development Branch Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/adrg/frontmatter/CONTRIBUTING.md Fetch the latest changes from the upstream repository to your local development branch. Ensure your local branch is up-to-date before starting new work. ```bash git checkout git pull upstream ``` -------------------------------- ### Serve Directory with Golang HTTP Server Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/gdamore/tcell/v2/README-wasm.md A simple Go HTTP server to serve files for standalone WASM Tcell projects. Ensure the path points to the directory containing your WASM files. ```golang // server.go package main import ( "log" "net/http" ) func main() { log.Fatal(http.ListenAndServe(":8080", http.FileServer(http.Dir("/path/to/dir/to/serve")), )) } ``` -------------------------------- ### Run All Tests Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/spf13/cobra/CONTRIBUTING.md Execute all tests for the project to ensure code quality. This command is useful before submitting changes. ```shell go test ./... ``` -------------------------------- ### Initialize Tcell Screen Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/gdamore/tcell/v2/TUTORIAL.md Creates and initializes a new Tcell screen. Handles potential errors during creation and initialization. Sets a default style and clears the screen. ```go s, err := tcell.NewScreen() if err != nil { log.Fatalf("%+v", err) } if err := s.Init(); err != nil { log.Fatalf("%+v", err) } // Set default text style defStyle := tcell.StyleDefault.Background(tcell.ColorReset).Foreground(tcell.ColorReset) s.SetStyle(defStyle) // Clear screen s.Clear() ``` -------------------------------- ### Custom Front Matter Formats with frontmatter.Parse Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/adrg/frontmatter/README.md Shows how to use custom front matter formats by providing a slice of frontmatter.Format. This allows parsing content with non-standard front matter delimiters or structures. ```go package main import ( "fmt" "strings" "github.com/adrg/frontmatter" "gopkg.in/yaml.v2" ) var input = ` ... name: "frontmatter" tags: ["go", "yaml", "json", "toml"] ... rest of the content` func main() { var matter struct { Name string `yaml:"name"` Tags []string `yaml:"tags"` } formats := []*frontmatter.Format{ frontmatter.NewFormat("...", "...", yaml.Unmarshal), } rest, err := frontmatter.Parse(strings.NewReader(input), &matter, formats...) if err != nil { // Treat error. } // NOTE: If a front matter must be present in the input data, use // frontmatter.MustParse instead. fmt.Printf("%+v\n", matter) fmt.Println(string(rest)) // Output: // {Name:frontmatter Tags:[go yaml json toml]} // rest of the content } ``` -------------------------------- ### Convert Color to Various Spaces Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/lucasb-eyer/go-colorful/README.md Shows how to convert an existing color object into different color space representations like Hex, HSV, XYZ, XYY, Lab, Luv, and HCL. ```go hex := c.Hex() h, s, v := c.Hsv() x, y, z := c.Xyz() x, y, Y := c.Xyy() l, a, b := c.Lab() l, u, v := c.Luv() h, c, l := c.Hcl() ``` -------------------------------- ### Supporting Go Flags with pflag Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/spf13/pflag/README.md Shows how to integrate flags defined using Go's standard `flag` package into a pflag flagset, often needed for third-party dependencies. ```go import ( goflag "flag" flag "github.com/spf13/pflag" ) var ip *int = flag.Int("flagname", 1234, "help message for flagname") func main() { flag.CommandLine.AddGoFlagSet(goflag.CommandLine) flag.Parse() } ``` -------------------------------- ### Unmarshal and Marshal YAML Data in Go Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/gopkg.in/yaml.v3/README.md Demonstrates how to unmarshal YAML data into a Go struct and a map, and then marshal them back into YAML format. Ensure struct fields are public for correct unmarshalling. ```Go package main import ( "fmt" "log" "gopkg.in/yaml.v3" ) var data = ` a: Easy! b: c: 2 d: [3, 4] ` // Note: struct fields must be public in order for unmarshal to // correctly populate the data. type T struct { A string B struct { RenamedC int `yaml:"c"` D []int `yaml:",flow"` } } func main() { t := T{} err := yaml.Unmarshal([]byte(data), &t) if err != nil { log.Fatalf("error: %v", err) } fmt.Printf("--- t:\n%v\n\n", t) d, err := yaml.Marshal(&t) if err != nil { log.Fatalf("error: %v", err) } fmt.Printf("--- t dump:\n%s\n\n", string(d)) m := make(map[interface{}]interface{}) err = yaml.Unmarshal([]byte(data), &m) if err != nil { log.Fatalf("error: %v", err) } fmt.Printf("--- m:\n%v\n\n", m) d, err = yaml.Marshal(&m) if err != nil { log.Fatalf("error: %v", err) } fmt.Printf("--- m dump:\n%s\n\n", string(d)) } ``` -------------------------------- ### Check style attributes Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/ktr0731/go-ansisgr/README.md Shows how to check for foreground and background colors, as well as specific text attributes like bold and italic, from a parsed style. ```go if color, ok := style.Foreground(); ok { // Foreground color is specified. } if color, ok := style.Background(); ok { // Background color is specified. } ``` ```go style.Bold() style.Italic() ``` -------------------------------- ### Generate Random Palettes in Go Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/lucasb-eyer/go-colorful/README.md Shows how to generate arrays of distinguishable random colors using Warm, FastWarm, Happy, FastHappy, and Soft palettes. The non-fast methods may fail if too many colors are requested. ```go pal1, err1 := colorful.WarmPalette(10) pal2 := colorful.FastWarmPalette(10) pal3, err3 := colorful.HappyPalette(10) pal4 := colorful.FastHappyPalette(10) pal5, err5 := colorful.SoftPalette(10) ``` -------------------------------- ### Preselecting Items in FindMulti Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/ktr0731/go-fuzzyfinder/README.md Demonstrates preselecting multiple items in multi-selection mode using the WithPreselected option. All items matching the predicate will be initially selected. ```go // Multi selection mode // All items that match the predicate will be selected initially idxs, err := fuzzyfinder.FindMulti( tracks, func(i int) string { return tracks[i].Name }, fuzzyfinder.WithPreselected(func(i int) bool { return tracks[i].Artist == "artist2" }), ) ``` -------------------------------- ### Preselecting Items in Find Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/ktr0731/go-fuzzyfinder/README.md Shows how to preselect items in single selection mode using the WithPreselected option. The cursor will be positioned on the first item matching the predicate. ```go // Single selection mode // The cursor will be positioned on the first item that matches the predicate idx, err := fuzzyfinder.Find( tracks, func(i int) string { return tracks[i].Name }, fuzzyfinder.WithPreselected(func(i int) bool { return tracks[i].Name == "bar" }), ) ``` -------------------------------- ### Calculate String Width Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/mattn/go-runewidth/README.md Demonstrates how to calculate the display width of a string using the StringWidth function. This is useful for aligning text in terminals. ```go runewidth.StringWidth("つのだ☆HIRO") == 12 ``` -------------------------------- ### Unmarshal and Marshal YAML Data in Go Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/gopkg.in/yaml.v2/README.md Demonstrates how to unmarshal YAML data into a Go struct and a map, and then marshal them back into YAML format. Ensure struct fields are exported for unmarshalling. ```Go package main import ( "fmt" "log" "gopkg.in/yaml.v2" ) var data = ` a: Easy! b: c: 2 d: [3, 4] ` // Note: struct fields must be public in order for unmarshal to // correctly populate the data. type T struct { A string B struct { RenamedC int `yaml:"c"` D []int `yaml:",flow"` } } func main() { t := T{} err := yaml.Unmarshal([]byte(data), &t) if err != nil { log.Fatalf("error: %v", err) } fmt.Printf("--- t:\n%v\n\n", t) d, err := yaml.Marshal(&t) if err != nil { log.Fatalf("error: %v", err) } fmt.Printf("--- t dump:\n%s\n\n", string(d)) m := make(map[interface{}]interface{}) err = yaml.Unmarshal([]byte(data), &m) if err != nil { log.Fatalf("error: %v", err) } fmt.Printf("--- m:\n%v\n\n", m) d, err = yaml.Marshal(&m) if err != nil { log.Fatalf("error: %v", err) } fmt.Printf("--- m dump:\n%s\n\n", string(d)) } ``` -------------------------------- ### Search Content and Open in Editor Source: https://github.com/yakitrak/notesmd-cli/blob/main/README.md Searches for content in notes and opens the selected note in your default editor. Useful for immediate editing of search results. ```bash notesmd-cli search-content "search term" --editor ``` -------------------------------- ### Print Note by Path Source: https://github.com/yakitrak/notesmd-cli/blob/main/README.md Prints the content of a note using its full path within the default Obsidian vault. Useful for disambiguating notes with similar names. ```bash notesmd-cli print "{note-path}" ``` -------------------------------- ### System Call Entry Points Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/golang.org/x/sys/unix/README.md Defines the entry points for system call dispatch in assembly files. These functions handle passing arguments to the kernel and returning results. ```go func Syscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr) func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr) func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr) ``` -------------------------------- ### Convert image/color.Color to colorful.Color Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/lucasb-eyer/go-colorful/README.md Demonstrates converting a standard Go `color.Color` interface type into a `colorful.Color` object using the `MakeColor` function. ```go c, ok := colorful.MakeColor(color.Gray16{12345}) ``` -------------------------------- ### Reading HexColor from Database Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/lucasb-eyer/go-colorful/README.md Demonstrates how to scan a HexColor value from a database query using the sql.Scanner interface. Ensure RGB values are within the 0-1 range. ```go var hc HexColor _, err := db.QueryRow("SELECT '#ff0000';").Scan(&hc) // hc == HexColor{R: 1, G: 0, B: 0}; err == nil ``` -------------------------------- ### Import pflag as flag Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/spf13/pflag/README.md Import the pflag library with the alias 'flag' to maintain compatibility with existing Go flag package code. ```go import flag "github.com/spf13/pflag" ``` -------------------------------- ### Create or Open Daily Note Source: https://github.com/yakitrak/notesmd-cli/blob/main/README.md Directly create or open today's daily note. The command respects daily note configuration (folder, format, template) from `.obsidian/daily-notes.json` if it exists in the vault. ```bash # Creates / opens daily note in obsidian vault notesmd-cli daily # Creates / opens daily note in specified obsidian vault notesmd-cli daily --vault "{vault-name}" ``` -------------------------------- ### Default Usage of frontmatter.Parse Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/adrg/frontmatter/README.md Demonstrates parsing content with default front matter formats (YAML, JSON, TOML). The parsed front matter is stored in the provided struct, and the rest of the content is returned. ```go package main import ( "fmt" "strings" "github.com/adrg/frontmatter" ) var input = ` --- name: "frontmatter" tags: ["go", "yaml", "json", "toml"] --- rest of the content` func main() { var matter struct { Name string `yaml:"name"` Tags []string `yaml:"tags"` } rest, err := frontmatter.Parse(strings.NewReader(input), &matter) if err != nil { // Treat error. } // NOTE: If a front matter must be present in the input data, use // frontmatter.MustParse instead. fmt.Printf("%+v\n", matter) fmt.Println(string(rest)) // Output: // {Name:frontmatter Tags:[go yaml json toml]} // rest of the content } ``` -------------------------------- ### Fast Linear RGB Approximation Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/lucasb-eyer/go-colorful/README.md Provides a faster approximation for Linear RGB conversions, suitable for tight loops. Accuracy is within 0.5% but drops significantly if input values are outside the 0-1 range. ```go col := // Get your color somehow l, a, b := XyzToLab(LinearRgbToXyz(col.LinearRgb())) ``` -------------------------------- ### Manual Vault Configuration for Headless Use Source: https://github.com/yakitrak/notesmd-cli/blob/main/README.md Manually configure Obsidian vaults in `~/.config/obsidian/obsidian.json` for headless CLI usage. Ensure to use absolute paths and avoid '~'. ```json { "vaults": { "any-unique-id": { "path": "/home/user/vaults/my-brain" } } } ``` -------------------------------- ### Standard Go Error Handling Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/pkg/errors/README.md Illustrates the traditional error handling idiom in Go, which can lead to a lack of context. ```Go if err != nil { return err } ``` -------------------------------- ### Basic Command Line Flag Syntax Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/spf13/pflag/README.md Illustrates the syntax for boolean flags and flags with or without default values, using double dashes for long-form flags. ```bash --flag // boolean flags, or flags with no option default values --flag x // only on flags without a default value --flag=x ``` -------------------------------- ### Custom Flag Name Normalization Function Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/spf13/pflag/README.md Shows how to set a custom normalization function to treat flags with different separators (-, _, .) as equivalent. ```go func wordSepNormalizeFunc(f *pflag.FlagSet, name string) pflag.NormalizedName { from := []string{"-", "_"} to := "." for _, sep := range from { name = strings.Replace(name, sep, to, -1) } return pflag.NormalizedName(name) } myFlagSet.SetNormalizeFunc(wordSepNormalizeFunc) ``` -------------------------------- ### Set Default Vault and Open Type Source: https://github.com/yakitrak/notesmd-cli/blob/main/README.md Configure the default Obsidian vault and the preferred method for opening notes (Obsidian application or default editor). These settings apply to subsequent commands unless overridden. ```bash # Set default vault (by name or path) notesmd-cli set-default-vault "{vault-name}" # Set default open type: 'obsidian' (default) or 'editor' notesmd-cli set-default-vault --open-type editor # Set both at once notesmd-cli set-default-vault "{vault-name}" --open-type editor ``` -------------------------------- ### Uninstall obsidian-cli (Arch Linux AUR) Source: https://github.com/yakitrak/notesmd-cli/blob/main/MIGRATION.md Uninstall the old version from Arch Linux AUR using yay or paru. ```bash # Using yay yay -R obsidian-cli-bin # Using paru paru -R obsidian-cli-bin ``` -------------------------------- ### Clone Cobra Fork Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/spf13/cobra/CONTRIBUTING.md Download your forked copy of the Cobra project to your local machine. Navigate into the project directory after cloning. ```shell git clone https://github.com/your_username/cobra && cd cobra ``` -------------------------------- ### Shorthand Command Line Flag Syntax Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/spf13/pflag/README.md Demonstrates the use of single dashes for shorthand flag combinations, distinguishing between boolean/defaulted flags and non-boolean/non-defaulted flags. ```bash // boolean or flags where the 'no option default value' is set -f -f=true -abc but -b true is INVALID // non-boolean and flags without a 'no option default value' -n 1234 -n=1234 -n1234 // mixed -abcs "hello" -absd="hello" -abcs1234 ``` -------------------------------- ### Compare Colors Using Different Distance Metrics Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/lucasb-eyer/go-colorful/README.md Compares two pairs of colors using various distance metrics including RGB, Lab, Luv, CIE76, CIE94, and CIEDE2000. It highlights the perceptual differences shown by CIE-based metrics. ```go package main import "fmt" import "github.com/lucasb-eyer/go-colorful" func main() { c1a := colorful.Color{150.0 / 255.0, 10.0 / 255.0, 150.0 / 255.0} c1b := colorful.Color{53.0 / 255.0, 10.0 / 255.0, 150.0 / 255.0} c2a := colorful.Color{10.0 / 255.0, 150.0 / 255.0, 50.0 / 255.0} c2b := colorful.Color{99.9 / 255.0, 150.0 / 255.0, 10.0 / 255.0} fmt.Printf("DistanceRgb: c1: %v\tand c2: %v\n", c1a.DistanceRgb(c1b), c2a.DistanceRgb(c2b)) fmt.Printf("DistanceLab: c1: %v\tand c2: %v\n", c1a.DistanceLab(c1b), c2a.DistanceLab(c2b)) fmt.Printf("DistanceLuv: c1: %v\tand c2: %v\n", c1a.DistanceLuv(c1b), c2a.DistanceLuv(c2b)) fmt.Printf("DistanceCIE76: c1: %v\tand c2: %v\n", c1a.DistanceCIE76(c1b), c2a.DistanceCIE76(c2b)) fmt.Printf("DistanceCIE94: c1: %v\tand c2: %v\n", c1a.DistanceCIE94(c1b), c2a.DistanceCIE94(c2b)) fmt.Printf("DistanceCIEDE2000: c1: %v\tand c2: %v\n", c1a.DistanceCIEDE2000(c1b), c2a.DistanceCIEDE2000(c2b)) } ``` -------------------------------- ### Import Cobra in Go Application Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/spf13/cobra/README.md Include the Cobra library in your Go application by importing the package. ```go import "github.com/spf13/cobra" ``` -------------------------------- ### Build Tcell Project for WASM Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/gdamore/tcell/v2/README-wasm.md Use these flags to compile your Tcell project into a WebAssembly binary. ```sh GOOS=js GOARCH=wasm go build -o yourfile.wasm ``` -------------------------------- ### Clean Up Old Config (Linux/Mac) Source: https://github.com/yakitrak/notesmd-cli/blob/main/MIGRATION.md Remove the old obsidian-cli configuration directory on Linux or macOS. ```bash rm -rf ~/.config/obsidian-cli # or rm -rf ~/.obsidian-cli ``` -------------------------------- ### Move or Rename Note and Open in Obsidian Source: https://github.com/yakitrak/notesmd-cli/blob/main/README.md Moves or renames a note and then opens it in Obsidian. Useful for immediate verification or continuation of work. ```bash notesmd-cli move "{current-note-path}" "{new-note-path}" --open ``` -------------------------------- ### Create Empty Note Source: https://github.com/yakitrak/notesmd-cli/blob/main/README.md Creates a new, empty note with the specified name in the default Obsidian vault. Intermediate directories are created automatically. ```bash notesmd-cli create "{note-name}" ``` -------------------------------- ### Handle Key Press Events Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/gdamore/tcell/v2/TUTORIAL.md When a key is pressed, an EventKey is dispatched. This event provides modifiers, the key code, and the rune if applicable. Note that key release events are not available. ```go switch ev := ev.(type) { case *tcell.EventKey: mod, key, ch := ev.Mod(), ev.Key(), ev.Rune() logMessage(fmt.Sprintf("EventKey Modifiers: %d Key: %d Rune: %d", mod, key, ch)) } ``` -------------------------------- ### Create a New Topic Branch Source: https://github.com/yakitrak/notesmd-cli/blob/main/vendor/github.com/adrg/frontmatter/CONTRIBUTING.md Create a new branch for your feature, change, or fix. Base this new branch off the main project development branch to keep your work isolated and organized. ```bash git checkout -b ``` -------------------------------- ### Troubleshooting: Reload Shell Source: https://github.com/yakitrak/notesmd-cli/blob/main/MIGRATION.md If 'Command not found: notesmd-cli' error occurs, try reloading your shell. ```bash # Reload your shell exec $SHELL # Or check if it's installed but not in PATH which notesmd-cli ```