Add SnipCommand importer tool + move snips between CLIs#34
Merged
Conversation
Introduce `tools/Snipdeck.Importer`, a cross-platform .NET console tool
(`snipdeck-importer`) that imports command snippets from a SnipCommand export
into a Snipdeck store. SnipCommand's export is JSON despite its `.db`
extension, so it is parsed with System.Text.Json — no SQLite dependency.
Importer:
- `snipcommand <path>` subcommand (Spectre.Console.Cli), dry-run by default;
`--write` backs the store up, mints fresh ids, creates CLIs on demand and
skips duplicates. `--store`/`--cli`/`--into`/`--allow-duplicates` control it.
- `ISnippetSource` isolates format parsing; `ScMarkupTranslator` converts
`[sc_choice]`/`[sc_variable]` markup into `{token}` placeholders + structured
parameters (slugifying names, disambiguating collisions, defensively
sanitising untrusted input); `CliSuggester` derives the CLI from the first
token; `StoreMerger` plans/applies the merge with CLI-scoped de-duplication.
Core:
- Factor the data-path layout into `DefaultPaths` so the tool resolves the same
store/backup locations the desktop app uses; `WindowsPathProvider` now
delegates to it (behaviour unchanged).
- Share tag-list normalisation via `TagParser`, used by the snip editor and the
importer.
App:
- Snip editor gains a CLI selector, so a snip can be re-homed to a different
CLI — pairs with the importer's `--into` fallback.
Seed: a first-run `snipdeck-importer` CLI sits alongside Examples, with snips
that demonstrate the importer's own commands.
Also: bump Velopack 1.0.1 -> 1.1.1 (latest stable; the rest were current),
add an Ubuntu importer-tests CI job, and document the tool in its README plus
the repo README and CHANGELOG.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Implements the Importer backlog item from
TODO.md: a cross-platform .NET console tool,snipdeck-importer, that brings command snippets in from SnipCommand — plus two supporting changes that fell naturally out of it.1.
tools/Snipdeck.Importer— the importer toolsnipdeck-importer snipcommand <path>(Spectre.Console.Cli). Dry-run by default;--writeis the only path that mutates a store.--store,--write,--cli(force a CLI),--into(fallback CLI for unconfident suggestions),--allow-duplicates.--write: backs the store up first (honouring the desktop app's retention), mints fresh GUIDs, creates CLIs on demand, and skips duplicates — then warns to restart Snipdeck.Format finding: despite the
.dbextension, a SnipCommand export is pretty-printed JSON, not SQLite — so it's parsed withSystem.Text.Json(no new dependency). TheISnippetSourceadapter still header-sniffs so a real-SQLite source could slot in later.Pure, unit-tested pieces:
ScMarkupTranslator—[sc_choice]/[sc_variable]→{token}+ structuredParameter[]; slugifies names with spaces/punctuation ("Agreement ID"→AgreementID), disambiguates collisions, sanitises untrusted input, leaves malformed markup verbatim.CliSuggester— CLI from the first token, peeling launcher wrappers (sudo/npx) but not runtimes (pip).StoreMerger— purePlan+Apply; CLI-scoped de-duplication by(CLI, Title, CommandTemplate).2. Core: shared paths + tag parsing
DefaultPathscentralises the data-path layout so the tool resolves the same store/backup locations as the app;WindowsPathProvidernow delegates (behaviour unchanged).TagParsershares tag-CSV normalisation between the snip editor and the importer.3. App: move a snip to a different CLI
The snip editor gains a CLI selector (the editor already received the CLI list — it was just unused). Re-homes a snip on save; pairs with the importer's
--intofallback.4. First-run seed
A
snipdeck-importerCLI now sits alongside Examples, with snips demonstrating the importer's own commands.Also
importer-testsCI job.Testing
mpt-app/pip/inv-app;--writecreates the store + a backup; re-run skips all 25 as duplicates;--allow-duplicatesre-imports.CrossPlatformPathProvider, duplicated tag parsing) are addressed in this PR.🤖 Generated with Claude Code