diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 63b2fe9..3ba5b46 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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. diff --git a/Cargo.lock b/Cargo.lock index fb2d685..8268982 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -583,7 +583,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" [[package]] -name = "snip" +name = "snipr" version = "0.1.0" dependencies = [ "anyhow", diff --git a/Cargo.toml b/Cargo.toml index 778e38f..fa9a79b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,10 +1,13 @@ [package] -name = "snip" +name = "snipr" version = "0.1.0" edition = "2021" authors = ["Uriah G. "] -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] @@ -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] diff --git a/README.md b/README.md index 3f0a9ea..f954299 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -# 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. @@ -10,16 +10,24 @@ Note: This is an additional tools to be used with my [Neovide Neovim](https://gi ## 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 @@ -30,8 +38,8 @@ 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 @@ -39,7 +47,7 @@ chmod +x /usr/local/bin/snip 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" @@ -47,7 +55,7 @@ $env:Path += ";C:\Users\YourUsername\bin" ## Managing Multiple Snippets File for Different Languages -You can use the command `snip config ` to change the Snippets File on Runtime. +You can use the command `snipr config ` to change the Snippets File on Runtime. Note: This is quite useful when you want to manage different Snippets File for different languages. @@ -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 ```
Output ```sh -snip +snipr /Users/uriah/.config/nvim/snippets/rust/rust.json A CLI tool for managing Neovim LuaSnip Rust snippets -Usage: snip +Usage: snipr Commands: add Adds entry to Snippet Collection file @@ -96,38 +104,38 @@ Options: 2. Add new snippet ```sh # help -snip add --help +snipr add --help # Add Snippet -snip add --key --value --description -- "" +snipr add --key --value --description -- "" ``` 3. Remove snippet ```sh # help -snip remove --help +snipr remove --help # Remove Snippet -snip remove --key +snipr remove --key ``` 4. List all snippets ```sh # help -snip ls --help +snipr ls --help # Usage -snip ls +snipr ls # List all Keys -snip ls key +snipr ls key # List all Prefixes -snip ls prefix +snipr ls prefix ```
Output ```sh -snip ls key +snipr ls key /Users/uriah/.config/nvim/snippets/rust/rust.json [src/main.rs:468] list_option = Key impl_iterator @@ -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 --new-key +snipr update-key --old-key --new-key ```
Output ```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" @@ -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 --prefix --description -- "" +snipr edit --help +# Update snippet Value +snipr edit --key --prefix --description -- "" ``` 7. Search Snippet ```sh # help -snip search --help +snipr search --help # Search Snippet -snip search -- "" +snipr search -- "" ```
Output ```sh -snip search key -- impl +snipr search key -- impl /Users/uriah/.config/nvim/snippets/rust/rust.json [src/main.rs:490] id = Some( Key, @@ -208,16 +216,16 @@ impl_partialeq_single_field ```sh # help -snip show --help +snipr show --help # Show Snippet -snip show +snipr show ```
Output ```sh -snip show impl_deref +snipr show impl_deref /Users/uriah/.config/nvim/snippets/rust/rust.json [src/main.rs:484] &key = "impl_deref" +-------------+-------------------------------------------------------------+ @@ -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 +snipr config ``` diff --git a/provision.sh b/provision.sh index b411885..dfe0a6c 100755 --- a/provision.sh +++ b/provision.sh @@ -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 \ No newline at end of file +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 \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 29f630b..af02058 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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]