From c61dcb4f150d904b1b7af98bc090fe189e2d296d Mon Sep 17 00:00:00 2001 From: Mitchell Stanley Date: Tue, 4 Jun 2019 15:19:24 +0100 Subject: [PATCH 1/6] Make CLI version update automatically --- src/snipline_cli.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/snipline_cli.cr b/src/snipline_cli.cr index b4021ca..030a73b 100644 --- a/src/snipline_cli.cr +++ b/src/snipline_cli.cr @@ -9,7 +9,7 @@ require "./snipline_cli/commands/*" require "toml" module SniplineCli - VERSION = "0.1.3" + VERSION = "0.1.4" def self.config SniplineCli::Config.config @@ -28,7 +28,7 @@ module SniplineCli # This command is not used by itself # It is here to set up usage for other commands. class Command < Admiral::Command - define_version "0.1.3" + define_version SniplineCli::VERSION define_help description: "Snipline CLI" def run From 11426d8b3576ba873ed0668be79e7c34c0002c75 Mon Sep 17 00:00:00 2001 From: Mitchell Stanley Date: Tue, 4 Jun 2019 15:19:36 +0100 Subject: [PATCH 2/6] Bump shard version number --- shard.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shard.yml b/shard.yml index 484f249..4d7b187 100644 --- a/shard.yml +++ b/shard.yml @@ -1,5 +1,5 @@ name: snipline_cli -version: 0.1.3 +version: 0.1.4 authors: - Mitchell Stanley From c5c137d52cabb995fb40eaaaffc38d7e693f719b Mon Sep 17 00:00:00 2001 From: Mitchell Stanley Date: Tue, 4 Jun 2019 15:20:55 +0100 Subject: [PATCH 3/6] Fix command reference in the login command --- src/snipline_cli/commands/login.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/snipline_cli/commands/login.cr b/src/snipline_cli/commands/login.cr index 5eb1cf5..6a5d4f9 100644 --- a/src/snipline_cli/commands/login.cr +++ b/src/snipline_cli/commands/login.cr @@ -62,7 +62,7 @@ module SniplineCli SniplineCli::Services::CreateConfigDirectory.run(SniplineCli.config_file) File.write(File.expand_path(SniplineCli.config_file), toml_contents, mode: "w") puts "Configuration saved to #{File.expand_path(SniplineCli.config_file).colorize.mode(:bold)}" - puts "To fetch your snippets run #{"snipline sync".colorize.mode(:bold)}" + puts "To fetch your snippets run #{"snipcli sync".colorize.mode(:bold)}" end rescue ex : Crest::NotFound puts "404 Not Found :(" From d82b3f99d354368d9d5f745cb2f488c568a357ce Mon Sep 17 00:00:00 2001 From: Mitchell Stanley Date: Tue, 4 Jun 2019 15:36:14 +0100 Subject: [PATCH 4/6] Better instructions for using snipline without account --- README.md | 22 +++++++++++++++++++++- src/snipline_cli/commands/init.cr | 3 ++- src/snipline_cli/commands/search.cr | 2 +- src/snipline_cli/models/snippet.cr | 2 +- 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index fc14861..42737c5 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ snipcli web -p 3000 -b 0.0.0.0 ### Using Snipline CLI without a Snipline Account -Snipline CLI can be used without an active Snipline account. But requires either manually entering data in the `snippets.json` file or using the `web` interface. +Snipline CLI can be used without an active Snipline account. But requires either manually entering data in the `~/.config/snipline/snippets.json` file or using the `web` interface. To generate the initial configuration files use the `init` command. @@ -85,6 +85,26 @@ To generate the initial configuration files use the `init` command. snipcli init ``` +At this moment the web interface does not support CRUD commands and manual entry is required. + +Here is an example ~/.config/snipline/snipets.json` file to get started. + +```json +[ + { + "id":null, + "type":"snippets", + "attributes": + { + "is-pinned":false, + "name":"Symlink directory", + "real-command":"ln -s #{[Source]} #{[Destination]}", + "tags":["file", "linux"] + } + } +] +``` + ## Development See the Installation section on building from source. diff --git a/src/snipline_cli/commands/init.cr b/src/snipline_cli/commands/init.cr index 4310d24..283bc00 100644 --- a/src/snipline_cli/commands/init.cr +++ b/src/snipline_cli/commands/init.cr @@ -26,7 +26,8 @@ module SniplineCli SniplineCli::Services::CreateConfigDirectory.run(SniplineCli.config_file) File.write(File.expand_path(SniplineCli.config_file), toml_contents, mode: "w") puts "Configuration saved to #{File.expand_path(SniplineCli.config_file).colorize.mode(:bold)}" - puts "To fetch your snippets run #{"snipline sync".colorize.mode(:bold)}" + puts "Add your snippets to #{File.expand_path(config.get("general.file"))}" + puts "See documentation for more information https://github.com/snipline/snipcli#using-snipline-cli-without-a-snipline-account" end end diff --git a/src/snipline_cli/commands/search.cr b/src/snipline_cli/commands/search.cr index c12b6fa..dc3852f 100644 --- a/src/snipline_cli/commands/search.cr +++ b/src/snipline_cli/commands/search.cr @@ -96,7 +96,7 @@ module SniplineCli end end else - p "Snippet does not exist" + puts "Snippet does not exist" end else puts "You did not select a snippet." diff --git a/src/snipline_cli/models/snippet.cr b/src/snipline_cli/models/snippet.cr index 9a78521..77ad5dc 100644 --- a/src/snipline_cli/models/snippet.cr +++ b/src/snipline_cli/models/snippet.cr @@ -3,7 +3,7 @@ require "json" module SniplineCli class Snippet JSON.mapping({ - id: String, + id: String | Nil, type: String, attributes: SnippetAttribute, }) From 5b3ae8a54424af774626107095e525cee47dc29b Mon Sep 17 00:00:00 2001 From: Mitchell Stanley Date: Tue, 4 Jun 2019 15:41:52 +0100 Subject: [PATCH 5/6] Show when snippet is not saved to server in search --- src/snipline_cli/commands/search.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/snipline_cli/commands/search.cr b/src/snipline_cli/commands/search.cr index dc3852f..d33b1c3 100644 --- a/src/snipline_cli/commands/search.cr +++ b/src/snipline_cli/commands/search.cr @@ -75,7 +75,7 @@ module SniplineCli end results.each_with_index { |snippet, index| - puts "#{(index + 1).to_s.rjust(4)} #{snippet.name.colorize(:green)} #{snippet.is_pinned ? "⭐️" : ""}#{(snippet.tags.size > 0) ? "[" + snippet.tags.join(",") + "]" : ""}".colorize.mode(:bold) + puts "#{(index + 1).to_s.rjust(4)} #{snippet.name.colorize(:green)} #{snippet.is_pinned ? "⭐️" : ""}#{snippet.id.nil? ? "⚡️" : ""} #{(snippet.tags.size > 0) ? "[" + snippet.tags.join(",") + "]" : ""}".colorize.mode(:bold) puts " #{snippet.preview_command}" } From a91bf717cdd24e00828dd3bf5124adbb3b3feddd Mon Sep 17 00:00:00 2001 From: Mitchell Stanley Date: Tue, 4 Jun 2019 15:44:18 +0100 Subject: [PATCH 6/6] documentation on snippets with null id --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 42737c5..07239af 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,8 @@ At this moment the web interface does not support CRUD commands and manual entry Here is an example ~/.config/snipline/snipets.json` file to get started. +Note that `id` of `null` means that it has not been synced to a Snipline account. It will be lost if `snipcli sync` is ever run to fetch snippets from Snipline. + ```json [ {