MCPcopy Index your code
hub / github.com/nikivdev/go / runOpenSqlite

Function runOpenSqlite

cli/flow/main.go:1701–1743  ·  view source on GitHub ↗
(ctx *snap.Context)

Source from the content-addressed store, hash-verified

1699}
1700
1701func runOpenSqlite(ctx *snap.Context) error {
1702 if ctx.NArgs() != 0 {
1703 fmt.Fprintf(ctx.Stderr(), "Usage: %s openSqlite\n", commandName)
1704 return fmt.Errorf("expected 0 arguments, got %d", ctx.NArgs())
1705 }
1706
1707 workingDir, err := os.Getwd()
1708 if err != nil {
1709 return reportError(ctx, fmt.Errorf("determine working directory: %w", err))
1710 }
1711
1712 files, err := findSqliteFiles(workingDir)
1713 if err != nil {
1714 return reportError(ctx, fmt.Errorf("scan for .sqlite files: %w", err))
1715 }
1716
1717 if len(files) == 0 {
1718 fmt.Fprintf(ctx.Stdout(), "No .sqlite files found under %s\n", workingDir)
1719 return nil
1720 }
1721
1722 idx, err := fuzzyfinder.Find(
1723 files,
1724 func(i int) string {
1725 return files[i].Relative
1726 },
1727 fuzzyfinder.WithPromptString("openSqlite> "),
1728 )
1729 if err != nil {
1730 if errors.Is(err, fuzzyfinder.ErrAbort) {
1731 return nil
1732 }
1733 return reportError(ctx, fmt.Errorf("select sqlite file: %w", err))
1734 }
1735
1736 selected := files[idx]
1737 if err := openInTablePlus(ctx, selected.Absolute); err != nil {
1738 return reportError(ctx, err)
1739 }
1740
1741 fmt.Fprintf(ctx.Stdout(), "✔️ Opened %s in TablePlus\n", selected.Relative)
1742 return nil
1743}
1744
1745func runFocusCursorWindow(ctx *snap.Context) error {
1746 if ctx.NArgs() != 0 {

Callers 1

mainFunction · 0.85

Calls 3

reportErrorFunction · 0.85
findSqliteFilesFunction · 0.85
openInTablePlusFunction · 0.85

Tested by

no test coverage detected