Skip to content

Commit

Permalink
from snip to snipr
Browse files Browse the repository at this point in the history
  • Loading branch information
codeitlikemiley committed Dec 18, 2023
1 parent 0aa03a8 commit 3f0aef7
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 63 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
with:
# (required) Comma-separated list of binary names (non-extension portion of filename) to build and upload.
# Note that glob pattern is not supported yet.
bin: snip
bin: snipr
# (optional) Target triple, default is host triple.
target: ${{ matrix.target }}
# (required) GitHub token for uploading assets to GitHub Releases.
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 13 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
[package]
name = "snip"
name = "snipr"
version = "0.1.0"
edition = "2021"
authors = ["Uriah G. <codeitlikemiley@gmail.com>"]
description = "A CLI tool for managing Neovim LuaSnip Rust snippets"

description = "A CLI tool (snipr) for managing Neovim and VSCode snippets"
readme = "README.md"
license = "MIT"
keywords = ["neovim", "snippets", "rust", "cli", "vscode"]
categories = ["command-line-utilities"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
Expand All @@ -19,14 +22,16 @@ dirs-next = "2.0.0"
dotenv = { version = "0.15.0", features = ["clap"] }

[package.metadata.bundle]
name = "snip" # The name of your application
identifier = "com.codeitlikemiley.snip" # The bundle identifier of your application
name = "snipr" # The name of your application
identifier = "com.codeitlikemiley.snipr" # The bundle identifier of your application
copyright = "Copyright (c) codeitlikemiley 2023. All rights reserved."
category = "Developer Tool"
short_description = "A CLI tool for managing Neovim LuaSnip Rust snippets"
long_description = "A CLI tool for managing Neovim LuaSnip Rust snippets"
short_description = "A CLI tool for managing Neovim and VSCode snippets"
long_description = "A CLI tool for managing Neovim and VSCode snippets"
version = "0.1.0" # Version of your application
osx_url_schemes = ["com.codeitlikemiley.snip"] # URL schemes your application supports
osx_url_schemes = [
"com.codeitlikemiley.snipr",
] # URL schemes your application supports
script = "scripts/postinstall" # Path to your postinstall script

[profile.release]
Expand Down
82 changes: 45 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
# CLI Tool for Managing Neovim and VSCode Snippets
# A CLI (snipr) Tool for Managing Neovim and VSCode Snippets

[![Rust Build and Test](https://github.com/codeitlikemiley/snip/actions/workflows/test.yml/badge.svg)](https://github.com/codeitlikemiley/snip/actions/workflows/test.yml)
[![Rust Build and Test](https://github.com/codeitlikemiley/snipr/actions/workflows/test.yml/badge.svg)](https://github.com/codeitlikemiley/snipr/actions/workflows/test.yml)

[![release](https://github.com/codeitlikemiley/snip/actions/workflows/release.yml/badge.svg)](https://github.com/codeitlikemiley/snip/actions/workflows/release.yml)
[![release](https://github.com/codeitlikemiley/snipr/actions/workflows/release.yml/badge.svg)](https://github.com/codeitlikemiley/snipr/actions/workflows/release.yml)

Note: This is an additional tools to be used with my [Neovide Neovim](https://github.com/codeitlikemiley/nvim) rust setup.

> VSCode Snippet Compatible
## Installation

1. You can Download and Install [snip](https://github.com/codeitlikemiley/snip/releases) on Releases Page
1. You can Download and Install [snipr](https://github.com/codeitlikemiley/snipr/releases) on Releases Page
Note: on MacOS you might need to go to System Preferences > Security & Privacy > General and click Open Anyway to install it

Note: on Windows you might need to Add the command to ENV PATH

or Install it using Cargo

```sh
cargo install snipr
```



2. Build it from source
### Clone
```sh
git clone htps://github.com/codeitlikemiley/snip.git
cd snip
git clone htps://github.com/codeitlikemiley/snipr.git
cd snipr
```

### For MacOS
Expand All @@ -30,24 +38,24 @@ cd snip
### For Linux
```sh
cargo build --release
mv ./target/release/snip /usr/local/bin/snip
chmod +x /usr/local/bin/snip
mv ./target/release/snipr /usr/local/bin/snipr
chmod +x /usr/local/bin/snipr
```

### For Windows
```sh
cargo build --release

# Replace 'YourUsername' with your actual username
Move-Item .\target\release\snip.exe C:\Users\YourUsername\bin\snip.exe
Move-Item .\target\release\snipr.exe C:\Users\YourUsername\bin\snipr.exe

# Again, replace 'YourUsername' with your actual username
$env:Path += ";C:\Users\YourUsername\bin"
```

## Managing Multiple Snippets File for Different Languages

You can use the command `snip config <path>` to change the Snippets File on Runtime.
You can use the command `snipr config <path>` to change the Snippets File on Runtime.

Note: This is quite useful when you want to manage different Snippets File for different languages.

Expand All @@ -61,20 +69,20 @@ but you can change it by setting the `SNIP_CONFIG_PATH` environment variable.
1. Help

```sh
snip
snipr
# or
snip --help
snipr --help
```

<details>
<summary>Output</summary>

```sh
snip
snipr
/Users/uriah/.config/nvim/snippets/rust/rust.json
A CLI tool for managing Neovim LuaSnip Rust snippets

Usage: snip <COMMAND>
Usage: snipr <COMMAND>

Commands:
add Adds entry to Snippet Collection file
Expand All @@ -96,38 +104,38 @@ Options:
2. Add new snippet
```sh
# help
snip add --help
snipr add --help
# Add Snippet
snip add --key <key> --value <value> --description <description> -- "<snippet>"
snipr add --key <key> --value <value> --description <description> -- "<snippet>"
```
3. Remove snippet
```sh
# help
snip remove --help
snipr remove --help
# Remove Snippet
snip remove --key <key>
snipr remove --key <key>
```
4. List all snippets
```sh
# help
snip ls --help
snipr ls --help
# Usage
snip ls <LIST_OPTION | (key or prefix)>
snipr ls <LIST_OPTION | (key or prefix)>
# List all Keys
snip ls key
snipr ls key
# List all Prefixes
snip ls prefix
snipr ls prefix
```
<details>
<summary>Output</summary>
```sh
snip ls key
snipr ls key
/Users/uriah/.config/nvim/snippets/rust/rust.json
[src/main.rs:468] list_option = Key
impl_iterator
Expand All @@ -148,16 +156,16 @@ impl_clone_single_field
```sh
# help
snip update-key --help
snipr update-key --help
# Update Key
snip update-key --old-key <old-key> --new-key <new-key>
snipr update-key --old-key <old-key> --new-key <new-key>
```
<details>
<summary>Output</summary>
```sh
snip update-key --old-key "Fuzz match String" --new-key "fuzzy-match-string"
snipr update-key --old-key "Fuzz match String" --new-key "fuzzy-match-string"
/Users/uriah/.config/nvim/snippets/rust/rust.json
[src/main.rs:499] &old_key = "Fuzz match String"
[src/main.rs:499] &new_key = "fuzzy-match-string"
Expand All @@ -169,25 +177,25 @@ snip update-key --old-key "Fuzz match String" --new-key "fuzzy-match-string"
```sh
# help
snip edit --help
# Update Snippet Value
snip edit --key <key> --prefix <prefix> --description <description> -- "<snippet>"
snipr edit --help
# Update snippet Value
snipr edit --key <key> --prefix <prefix> --description <description> -- "<snippet>"
```
7. Search Snippet
```sh
# help
snip search --help
snipr search --help
# Search Snippet
snip search <ID | (key or prefix)> -- "<search_term>"
snipr search <ID | (key or prefix)> -- "<search_term>"
```
<details>
<summary>Output</summary>
```sh
snip search key -- impl
snipr search key -- impl
/Users/uriah/.config/nvim/snippets/rust/rust.json
[src/main.rs:490] id = Some(
Key,
Expand All @@ -208,16 +216,16 @@ impl_partialeq_single_field
```sh
# help
snip show --help
snipr show --help
# Show Snippet
snip show <key_id>
snipr show <key_id>
```
<details>
<summary>Output</summary>
```sh
snip show impl_deref
snipr show impl_deref
/Users/uriah/.config/nvim/snippets/rust/rust.json
[src/main.rs:484] &key = "impl_deref"
+-------------+-------------------------------------------------------------+
Expand Down Expand Up @@ -250,7 +258,7 @@ Note: This can be used to switch Configuration e.g. you wanna manage Python Snip

```sh
# help
snip config --help
snipr config --help
# Config Snippet
snip config <path>
snipr config <path>
```
4 changes: 2 additions & 2 deletions provision.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

cargo clean
rm snip.pkg
rm snipr.pkg
cargo zigbuild --release
cargo bundle --release
pkgbuild --root ./target/release/bundle/osx/snip.app --install-location "/Applications/snip.app" --identifier com.codeitlikemiley.snip --version 0.1.0 --scripts ./scripts snip.pkg
pkgbuild --root ./target/release/bundle/osx/snipr.app --install-location "/Applications/snipr.app" --identifier com.codeitlikemiley.snipr --version 0.1.0 --scripts ./scripts snipr.pkg
28 changes: 14 additions & 14 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
use anyhow::{self, Context, Result};
use clap::Parser;
use snip::actions::create_directory_and_file::create_directory_and_file;
use snip::actions::edit_snippet_in_file::edit_snippet_in_file;
use snip::actions::list_snippets::list_snippets;
use snip::actions::remove_snippet_from_file::remove_snippet_from_file;
use snip::actions::search_snippets::search_snippets;
use snip::actions::show_snippet::show_snippet;
use snip::actions::update_key_in_file::update_key_in_file;
use snip::actions::write_snippet_to_file::write_snippet_to_file;
use snip::constants::DEFAULT_SNIPPET_PATH;
use snip::helpers::expand_home_dir::expand_home_dir;
use snip::helpers::get_app_config::get_app_config;
use snip::models::cli_model::Cli;
use snip::models::commands_model::Commands;
use snip::models::snip_config_model::SnipConfig;
use snipr::actions::create_directory_and_file::create_directory_and_file;
use snipr::actions::edit_snippet_in_file::edit_snippet_in_file;
use snipr::actions::list_snippets::list_snippets;
use snipr::actions::remove_snippet_from_file::remove_snippet_from_file;
use snipr::actions::search_snippets::search_snippets;
use snipr::actions::show_snippet::show_snippet;
use snipr::actions::update_key_in_file::update_key_in_file;
use snipr::actions::write_snippet_to_file::write_snippet_to_file;
use snipr::constants::DEFAULT_SNIPPET_PATH;
use snipr::helpers::expand_home_dir::expand_home_dir;
use snipr::helpers::get_app_config::get_app_config;
use snipr::models::cli_model::Cli;
use snipr::models::commands_model::Commands;
use snipr::models::snip_config_model::SnipConfig;
use std::io::Write;

#[tokio::main]
Expand Down

0 comments on commit 3f0aef7

Please sign in to comment.