(ctx *snap.Context)
| 1699 | } |
| 1700 | |
| 1701 | func 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 | |
| 1745 | func runFocusCursorWindow(ctx *snap.Context) error { |
| 1746 | if ctx.NArgs() != 0 { |
no test coverage detected