Skip to content

Commit

Permalink
Merge branch 'release/0.1.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
Mitchell Stanley committed Jun 4, 2019
2 parents 77c91bc + a91bf71 commit 9e3e64b
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 9 deletions.
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,36 @@ 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.

```bash
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.

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
[
{
"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.
Expand Down
2 changes: 1 addition & 1 deletion shard.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: snipline_cli
version: 0.1.3
version: 0.1.4

authors:
- Mitchell Stanley <[email protected]>
Expand Down
4 changes: 2 additions & 2 deletions src/snipline_cli.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/snipline_cli/commands/init.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/snipline_cli/commands/login.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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 :("
Expand Down
4 changes: 2 additions & 2 deletions src/snipline_cli/commands/search.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
}

Expand All @@ -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."
Expand Down
2 changes: 1 addition & 1 deletion src/snipline_cli/models/snippet.cr
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ require "json"
module SniplineCli
class Snippet
JSON.mapping({
id: String,
id: String | Nil,
type: String,
attributes: SnippetAttribute,
})
Expand Down

0 comments on commit 9e3e64b

Please sign in to comment.