Skip to content

Commit

Permalink
Merge branch 'release/0.3.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Mitchell Stanley committed Jan 14, 2020
2 parents de2f095 + 1457e45 commit b61aa73
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 20 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## 0.3.1

### Changes

* Update temp snippet TOML file to include instructions for escaping quotes in commands and documentation

### Bugfixes

* Escape quotes in commands, documentation, and snippet name when editing a snippet
* Remove debug output after saving an edited snippet
* Always create a new temp snippet file even when it exists to prevent editing the wrong snippet

## 0.3.0

### Features
Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ install: build | $(INSTALL_DIR)
@rm -f $(SNIPCLI_SYSTEM)
@cp $(SNIPCLI) $(SNIPCLI_SYSTEM)

cp:
@rm -f $(SNIPCLI_SYSTEM)
@cp $(SNIPCLI) $(SNIPCLI_SYSTEM)

link: build | $(INSTALL_DIR)
@echo "Symlinking $(SNIPCLI) to $(SNIPCLI_SYSTEM)"
@ln -s $(SNIPCLI) $(SNIPCLI_SYSTEM)
Expand All @@ -39,4 +43,4 @@ clean:
rm -rf $(SNIPCLI)

distclean:
rm -rf $(SNIPCLI) .crystal .shards libs lib
rm -rf $(SNIPCLI) .crystal .shards libs lib
2 changes: 1 addition & 1 deletion shard.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: cli
version: 0.3.0
version: 0.3.1

authors:
- Mitchell Stanley <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion snap/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: snipcli
version: 0.3.0
version: 0.3.1
summary: Shell Snippet organiser
description: >
Snipcli is a commandline interface for managing shell commands. Sync commands with your Snipline account or use in guest mode. Snipline lets you dynamically change command parameters easily so you never have to remember how to build a command.
Expand Down
1 change: 0 additions & 1 deletion spec/services/migrator_spec.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
describe SniplineCli::Services::Migrator do

it "should create and migrate a DB from scratch" do
File.exists?("./test.db").should eq(false)
SniplineCli::Services::Migrator.run
Expand Down
2 changes: 1 addition & 1 deletion src/snipline_cli.cr
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module Repo
end

module SniplineCli
VERSION = "0.3.0"
VERSION = "0.3.1"

def self.config
Config.config
Expand Down
4 changes: 3 additions & 1 deletion src/snipline_cli/services/edit_snippet.cr
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ module SniplineCli
system("#{ENV["EDITOR"]} #{File.expand_path("#{config.get("general.temp_dir")}/temp.toml")}")
snippet_attributes = temp_file.read
snippet.name = snippet_attributes.name
snippet.real_command = snippet_attributes.real_command
snippet.real_command = snippet_attributes.real_command.strip
log.info(snippet.real_command.not_nil!)
log.info(snippet_attributes.real_command.not_nil!)
snippet.documentation = snippet_attributes.documentation
snippet.tags = (snippet_attributes.tags.nil?) ? nil : snippet_attributes.tags.not_nil!.join(",")
snippet.snippet_alias = snippet_attributes.snippet_alias
Expand Down
9 changes: 2 additions & 7 deletions src/snipline_cli/services/snipline_api.cr
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,9 @@ module SniplineCli::Services
"%F %T",
Time::Location::UTC
)
puts "cloud #{cloud_updated_at}"
local_snippet = Repo.get_by(Snippet, cloud_id: response.id.not_nil!)
if local_snippet
puts "local #{local_snippet.updated_at}"
end
Repo.get_by(Snippet, cloud_id: response.id.not_nil!)

q = Repo.raw_exec("UPDATE snippets SET updated_at=? WHERE cloud_id=?", cloud_updated_at, response.id)
puts q.inspect
Repo.raw_exec("UPDATE snippets SET updated_at=? WHERE cloud_id=?", cloud_updated_at, response.id)
end

def delete(snippet)
Expand Down
14 changes: 7 additions & 7 deletions src/snipline_cli/services/temp_snippet_editor_file.cr
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ module SniplineCli::Services
# This file uses TOML syntax and will be processed after the file is saved and closed
# Fill in the below options and save+quit to continue
name = ""
# Tip: When working with quotes make sure to escape doubles with \\ or switch to '''
real_command = """
echo 'hello, world'
echo 'hello, World'
"""
documentation = """
This section supports **Markdown**
Expand All @@ -26,12 +27,13 @@ sync_to_cloud = #{SniplineCli.config.get("api.token") == "" ? "false" : "true"}
@template = %<# Welcome to the terminal-based snippet editor
# This file uses TOML syntax and will be processed after the file is saved and closed
# Fill in the below options and save+quit to continue
name = "#{snippet.name}"
name = "#{snippet.name ? snippet.name.not_nil!.gsub("\"", "\\\"") : ""}"
# Tip: When working with quotes make sure to escape doubles with \\ or switch to '''
real_command = """
#{snippet.real_command}
#{snippet.real_command ? snippet.real_command.not_nil!.gsub("\"", "\\\"") : ""}
"""
documentation = """
#{snippet.documentation}
#{snippet.documentation ? snippet.documentation.not_nil!.gsub("\"", "\\\"") : ""}
"""
is_pinned = #{snippet.is_pinned}
snippet_alias = "#{snippet.snippet_alias}"
Expand All @@ -42,9 +44,7 @@ sync_to_cloud = #{SniplineCli.config.get("api.token") == "" ? "false" : "true"}

def create
config = SniplineCli.config
unless File.exists?(File.expand_path("#{config.get("general.temp_dir")}/temp.toml"))
File.write(File.expand_path("#{config.get("general.temp_dir")}/temp.toml"), @template)
end
File.write(File.expand_path("#{config.get("general.temp_dir")}/temp.toml"), @template)
end

def read
Expand Down

0 comments on commit b61aa73

Please sign in to comment.