snippet_cli 0.2.1 → 0.2.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -1
- data/Gemfile +17 -16
- data/README.md +43 -44
- data/Rakefile +4 -0
- data/lib/Setup.rb +73 -73
- data/lib/banner.rb +15 -15
- data/lib/snippet_cli/cli.rb +62 -58
- data/lib/{info.md → snippet_cli/commands/info.md} +19 -19
- data/lib/snippet_cli/commands/info.rb +2 -2
- data/lib/snippet_cli/commands/new.rb +113 -113
- data/lib/snippet_cli/commands/setup.rb +108 -108
- data/lib/snippet_cli/version.rb +1 -1
- data/lib/snippet_generator.rb +84 -84
- data/snippet_cli-0.1.0.gem +0 -0
- data/snippet_cli-0.1.1.gem +0 -0
- data/snippet_cli-0.1.2.gem +0 -0
- data/snippet_cli-0.1.3.gem +0 -0
- data/snippet_cli-0.1.4.gem +0 -0
- data/snippet_cli-0.1.5.gem +0 -0
- data/snippet_cli-0.1.6.gem +0 -0
- data/snippet_cli-0.1.7.gem +0 -0
- data/snippet_cli-0.1.8.gem +0 -0
- data/snippet_cli-0.1.9.gem +0 -0
- data/snippet_cli-0.2.0.gem +0 -0
- data/snippet_cli-0.2.1.gem +0 -0
- data/snippet_cli-0.2.2.gem +0 -0
- data/snippet_cli-0.2.3.gem +0 -0
- data/snippet_cli-0.2.4.gem +0 -0
- data/snippet_cli-0.2.6.gem +0 -0
- data/snippet_cli-0.2.7.gem +0 -0
- data/snippet_cli-0.2.8.gem +0 -0
- data/snippet_cli.gemspec +38 -37
- metadata +40 -8
- data/Gemfile.lock +0 -90
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8961277f704443a6959fcfe92a396e72724ac2f439aeaea9456f9a803b165e6d
|
4
|
+
data.tar.gz: 54241c7cc79cdd9c3fb86588ac55116bdef42053a9adc403d185334cac7989f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be4aa64bd286ef6593b3e008321966bebad41a64fb560fcfb2480e1a45ea933190a8e36a2d59c896838b5352d030bcade664cfcf4d6a83b7533083b46ce495b3
|
7
|
+
data.tar.gz: 525d825a3d0ba43b4dde72907be85196c54e1ec0d017ca74398721255e51dd14a18ee200657ac86224b4c78df2d2e7ebce96944d517eb9478a31236f9b141966
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -1,16 +1,17 @@
|
|
1
|
-
source "https://rubygems.org"
|
2
|
-
|
3
|
-
# Specify your gem's dependencies in snippet_cli.gemspec
|
4
|
-
gemspec
|
5
|
-
|
6
|
-
gem "rake"
|
7
|
-
gem "rspec", "~> 3.0"
|
8
|
-
gem "tty-prompt"
|
9
|
-
gem "tty-box"
|
10
|
-
gem "tty-platform"
|
11
|
-
gem 'tty-markdown'
|
12
|
-
gem "pastel"
|
13
|
-
gem "bundler"
|
14
|
-
gem "snippets_for_espanso"
|
15
|
-
gem "httparty"
|
16
|
-
gem "ascii"
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in snippet_cli.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
gem "rake"
|
7
|
+
gem "rspec", "~> 3.0"
|
8
|
+
gem "tty-prompt"
|
9
|
+
gem "tty-box"
|
10
|
+
gem "tty-platform"
|
11
|
+
gem 'tty-markdown'
|
12
|
+
gem "pastel"
|
13
|
+
gem "bundler"
|
14
|
+
gem "snippets_for_espanso"
|
15
|
+
gem "httparty"
|
16
|
+
gem "ascii"
|
17
|
+
gem "thor"
|
data/README.md
CHANGED
@@ -1,44 +1,43 @@
|
|
1
|
-
# SnippetCli
|
2
|
-
|
3
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/snippet_cli`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
6
|
-
|
7
|
-
## Installation
|
8
|
-
|
9
|
-
Add this line to your application's Gemfile:
|
10
|
-
|
11
|
-
```ruby
|
12
|
-
gem 'snippet_cli'
|
13
|
-
```
|
14
|
-
|
15
|
-
And then execute:
|
16
|
-
|
17
|
-
$ bundle install
|
18
|
-
|
19
|
-
Or install it yourself as:
|
20
|
-
|
21
|
-
$ gem install snippet_cli
|
22
|
-
|
23
|
-
## Usage
|
24
|
-
|
25
|
-
TODO: Write usage instructions here
|
26
|
-
|
27
|
-
## Development
|
28
|
-
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
-
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will
|
32
|
-
|
33
|
-
## Contributing
|
34
|
-
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/snippet_cli. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/snippet_cli/blob/master/CODE_OF_CONDUCT.md).
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
Copyright (c) 2020 AJ Markow. See [MIT License](LICENSE.txt) for further details.
|
1
|
+
# SnippetCli
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/snippet_cli`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'snippet_cli'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install snippet_cli
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will new a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/snippet_cli. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/snippet_cli/blob/master/CODE_OF_CONDUCT.md).
|
36
|
+
|
37
|
+
## Code of Conduct
|
38
|
+
|
39
|
+
Everyone interacting in the SnippetCli project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/snippet_cli/blob/master/CODE_OF_CONDUCT.md).
|
40
|
+
|
41
|
+
## Copyright
|
42
|
+
|
43
|
+
Copyright (c) 2020 AJ Markow. See [MIT License](LICENSE.txt) for further details.
|
data/Rakefile
CHANGED
data/lib/Setup.rb
CHANGED
@@ -1,74 +1,74 @@
|
|
1
|
-
require 'tty
|
2
|
-
require 'tty
|
3
|
-
prompt = TTY::Prompt.new
|
4
|
-
|
5
|
-
|
6
|
-
class Setup
|
7
|
-
@leading = " "
|
8
|
-
@divider = "------------------------------------"
|
9
|
-
attr_accessor :user_name,:user_os,:user_storage,:config_present
|
10
|
-
|
11
|
-
def initialize(user_name,user_os,user_storage,config_present)
|
12
|
-
@user_name = user_name
|
13
|
-
@user_os = user_os
|
14
|
-
@user_storage = user_storage
|
15
|
-
@config_present = config_present
|
16
|
-
end
|
17
|
-
|
18
|
-
class Error < StandardError; end
|
19
|
-
|
20
|
-
|
21
|
-
def get_name()
|
22
|
-
puts @leading
|
23
|
-
prompt = TTY::Prompt.new
|
24
|
-
name = prompt.ask("To begin setup, may I have your name?", default: ENV["USER"], active_color: :bright_blue) do |q|
|
25
|
-
q.required true
|
26
|
-
end
|
27
|
-
puts @leading
|
28
|
-
self.user_name = name
|
29
|
-
end
|
30
|
-
|
31
|
-
def get_os()
|
32
|
-
puts @leading
|
33
|
-
prompt = TTY::Prompt.new
|
34
|
-
config_path = prompt.ask("What OS are you using?", default: ENV["OS"], active_color: :bright_blue) do |q|
|
35
|
-
q.required true
|
36
|
-
end
|
37
|
-
if (config_path.include? "Windows")
|
38
|
-
return config_path = "\\Roaming\\AppData\\espanso\\default.yml"
|
39
|
-
elsif (config_path.include?"OS X")
|
40
|
-
return config_path = "
|
41
|
-
else config_path.include?("Linux")
|
42
|
-
return config_path = "
|
43
|
-
end
|
44
|
-
puts @leading
|
45
|
-
self.user_os=config_path
|
46
|
-
end
|
47
|
-
|
48
|
-
# REFACTOR TO PROVIDE PATH
|
49
|
-
def get_storage()
|
50
|
-
puts @leading
|
51
|
-
prompt = TTY::Prompt.new
|
52
|
-
return snippet_storage = prompt.select("Do your store your snippets in Dropbox or a different directory?", default: 1, active_color: :bright_blue) do |menu|
|
53
|
-
menu.enum "."
|
54
|
-
|
55
|
-
menu.choice "No I use the default folder.", 1
|
56
|
-
menu.choice "I use Dropbox.", 2
|
57
|
-
menu.choice "I use Google Drive", 3
|
58
|
-
menu.choice "I use Another Directory.", 4
|
59
|
-
end
|
60
|
-
puts @leading
|
61
|
-
self.user_storage = snippet_storage
|
62
|
-
end
|
63
|
-
|
64
|
-
def generate_config()
|
65
|
-
if File.exist?("
|
66
|
-
|
67
|
-
else
|
68
|
-
File.open("
|
69
|
-
File.open("
|
70
|
-
File.open("
|
71
|
-
File.open("
|
72
|
-
end
|
73
|
-
end
|
1
|
+
require 'tty-prompt'
|
2
|
+
require 'tty-box'
|
3
|
+
prompt = TTY::Prompt.new
|
4
|
+
|
5
|
+
|
6
|
+
class Setup
|
7
|
+
@leading = " "
|
8
|
+
@divider = "------------------------------------"
|
9
|
+
attr_accessor :user_name,:user_os,:user_storage,:config_present
|
10
|
+
|
11
|
+
def initialize(user_name,user_os,user_storage,config_present)
|
12
|
+
@user_name = user_name
|
13
|
+
@user_os = user_os
|
14
|
+
@user_storage = user_storage
|
15
|
+
@config_present = config_present
|
16
|
+
end
|
17
|
+
|
18
|
+
class Error < StandardError; end
|
19
|
+
|
20
|
+
|
21
|
+
def get_name()
|
22
|
+
puts @leading
|
23
|
+
prompt = TTY::Prompt.new
|
24
|
+
name = prompt.ask("To begin setup, may I have your name?", default: ENV["USER"], active_color: :bright_blue) do |q|
|
25
|
+
q.required true
|
26
|
+
end
|
27
|
+
puts @leading
|
28
|
+
self.user_name = name
|
29
|
+
end
|
30
|
+
|
31
|
+
def get_os()
|
32
|
+
puts @leading
|
33
|
+
prompt = TTY::Prompt.new
|
34
|
+
config_path = prompt.ask("What OS are you using?", default: ENV["OS"], active_color: :bright_blue) do |q|
|
35
|
+
q.required true
|
36
|
+
end
|
37
|
+
if (config_path.include? "Windows")
|
38
|
+
return config_path = "\\Roaming\\AppData\\espanso\\default.yml"
|
39
|
+
elsif (config_path.include?"OS X")
|
40
|
+
return config_path = "#{ENV["HOME"]}/Library/Preferences/espanso/default.yml"
|
41
|
+
else config_path.include?("Linux")
|
42
|
+
return config_path = "#{ENV["HOME"]}/.config/espanso/default.yml"
|
43
|
+
end
|
44
|
+
puts @leading
|
45
|
+
self.user_os=config_path
|
46
|
+
end
|
47
|
+
|
48
|
+
# REFACTOR TO PROVIDE PATH
|
49
|
+
def get_storage()
|
50
|
+
puts @leading
|
51
|
+
prompt = TTY::Prompt.new
|
52
|
+
return snippet_storage = prompt.select("Do your store your snippets in Dropbox or a different directory?", default: 1, active_color: :bright_blue) do |menu|
|
53
|
+
menu.enum "."
|
54
|
+
|
55
|
+
menu.choice "No I use the default folder.", 1
|
56
|
+
menu.choice "I use Dropbox.", 2
|
57
|
+
menu.choice "I use Google Drive", 3
|
58
|
+
menu.choice "I use Another Directory.", 4
|
59
|
+
end
|
60
|
+
puts @leading
|
61
|
+
self.user_storage = snippet_storage
|
62
|
+
end
|
63
|
+
|
64
|
+
def generate_config()
|
65
|
+
if File.exist?("#{ENV["HOME"]}/snippet_cli_config.txt") then
|
66
|
+
|
67
|
+
else
|
68
|
+
File.open("#{ENV["HOME"]}/snippet_cli_config.txt", "a") { |f| f.write "NAME = #{self.user_name}\n"}
|
69
|
+
File.open("#{ENV["HOME"]}/snippet_cli_config.txt", "a") { |f| f.write "OS = #{self.user_os}\n"}
|
70
|
+
File.open("#{ENV["HOME"]}/snippet_cli_config.txt", "a") { |f| f.write "STORAGE = #{self.user_storage}\n"}
|
71
|
+
File.open("#{ENV["HOME"]}/snippet_cli_config.txt", "a") { |f| f.write "CONFIG_PRESENT = TRUE\n"}
|
72
|
+
end
|
73
|
+
end
|
74
74
|
end
|
data/lib/banner.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
require 'tty-box'
|
2
|
-
|
3
|
-
def show_banner()
|
4
|
-
box = TTY::Box::frame(width:67, height:11, border: :thick, align: :left) do
|
5
|
-
"
|
6
|
-
##### # # ### ###### ###### ####### #######
|
7
|
-
# # ## # # # # # # # #
|
8
|
-
# # # # # # # # # # #
|
9
|
-
##### # # # # ###### ###### ##### #
|
10
|
-
# # # # # # # # #
|
11
|
-
# # # ## # # # # #
|
12
|
-
##### # # ### # # ####### # CLI
|
13
|
-
"
|
14
|
-
end
|
15
|
-
puts box
|
1
|
+
require 'tty-box'
|
2
|
+
|
3
|
+
def show_banner()
|
4
|
+
box = TTY::Box::frame(width:67, height:11, border: :thick, align: :left) do
|
5
|
+
"
|
6
|
+
##### # # ### ###### ###### ####### #######
|
7
|
+
# # ## # # # # # # # #
|
8
|
+
# # # # # # # # # # #
|
9
|
+
##### # # # # ###### ###### ##### #
|
10
|
+
# # # # # # # # #
|
11
|
+
# # # ## # # # # #
|
12
|
+
##### # # ### # # ####### # CLI
|
13
|
+
"
|
14
|
+
end
|
15
|
+
puts box
|
16
16
|
end
|
data/lib/snippet_cli/cli.rb
CHANGED
@@ -1,58 +1,62 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'thor'
|
4
|
-
|
5
|
-
module SnippetCli
|
6
|
-
# Handle the application command line parsing
|
7
|
-
# and the dispatch to various command objects
|
8
|
-
#
|
9
|
-
# @api public
|
10
|
-
class CLI < Thor
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'thor'
|
4
|
+
|
5
|
+
module SnippetCli
|
6
|
+
# Handle the application command line parsing
|
7
|
+
# and the dispatch to various command objects
|
8
|
+
#
|
9
|
+
# @api public
|
10
|
+
class CLI < Thor
|
11
|
+
def self.exit_on_failure?
|
12
|
+
true
|
13
|
+
puts "Something went wrong, try again."
|
14
|
+
end
|
15
|
+
# Error raised by this runner
|
16
|
+
Error = Class.new(StandardError)
|
17
|
+
|
18
|
+
desc 'version', 'snippet_cli version'
|
19
|
+
def version
|
20
|
+
require_relative 'version'
|
21
|
+
puts "v#{SnippetCli::VERSION}"
|
22
|
+
end
|
23
|
+
map %w(--version -v) => :version
|
24
|
+
|
25
|
+
desc 'info [DOCS]', 'Show info and docs about using the program.'
|
26
|
+
method_option :help, aliases: '-h', type: :boolean,
|
27
|
+
desc: 'Shows you where you can find more documentation and leave feedback for the program.'
|
28
|
+
def info(docs = nil)
|
29
|
+
if options[:help]
|
30
|
+
invoke :help, ['info']
|
31
|
+
else
|
32
|
+
require_relative 'commands/info'
|
33
|
+
SnippetCli::Commands::Info.new(docs, options).execute
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
desc 'new', 'Guides you through adding a new snippet.'
|
38
|
+
method_option :help, aliases: '-h', type: :boolean,
|
39
|
+
desc: 'Adds a new snippet to your yml file.'
|
40
|
+
def new(*)
|
41
|
+
if options[:help]
|
42
|
+
invoke :help, ['new']
|
43
|
+
else
|
44
|
+
require_relative 'commands/new'
|
45
|
+
SnippetCli::Commands::New.new(options).execute
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
desc 'setup', 'Sets up snippet_cli to modify correct file.'
|
50
|
+
method_option :help, aliases: '-h', type: :boolean,
|
51
|
+
desc: 'Sets directory to write to snippet file in.'
|
52
|
+
def setup(*)
|
53
|
+
if options[:help]
|
54
|
+
invoke :help, ['setup']
|
55
|
+
else
|
56
|
+
require_relative 'commands/setup'
|
57
|
+
SnippetCli::Commands::Setup.new().execute
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
@@ -1,20 +1,20 @@
|
|
1
|
-
# Thanks for trying Snippet CLI!
|
2
|
-
|
3
|
-
Hi! Have any feedback?
|
4
|
-
We'd love to hear it.
|
5
|
-
Click the link below to send an email to the developer.
|
6
|
-
|
7
|
-
## Links
|
8
|
-
|
9
|
-
- [Install Espanso](https://espanso.org/)
|
10
|
-
- [Snippet CLI Github](https://www.github.com/ajmarkow/snippet_cli)
|
11
|
-
- [Snippet CLI Docs](https:/docs.snippetcli.com)
|
12
|
-
- [Email Me Feedback](mailto:aj@ajm.codes)
|
13
|
-
|
14
|
-
## Commands
|
15
|
-
|
16
|
-
| **Command** | **Purpose** |
|
17
|
-
|----------|:------------------:|
|
18
|
-
| setup | Sets up path to snippet file |
|
19
|
-
| new | Opens dialog to add new snippet or form. |
|
1
|
+
# Thanks for trying Snippet CLI!
|
2
|
+
|
3
|
+
Hi! Have any feedback?
|
4
|
+
We'd love to hear it.
|
5
|
+
Click the link below to send an email to the developer.
|
6
|
+
|
7
|
+
## Links
|
8
|
+
|
9
|
+
- [Install Espanso](https://espanso.org/)
|
10
|
+
- [Snippet CLI Github](https://www.github.com/ajmarkow/snippet_cli)
|
11
|
+
- [Snippet CLI Docs](https:/docs.snippetcli.com)
|
12
|
+
- [Email Me Feedback](mailto:aj@ajm.codes)
|
13
|
+
|
14
|
+
## Commands
|
15
|
+
|
16
|
+
| **Command** | **Purpose** |
|
17
|
+
|----------|:------------------:|
|
18
|
+
| setup | Sets up path to snippet file |
|
19
|
+
| new | Opens dialog to add new snippet or form. |
|
20
20
|
| info| Docs, Contact Info, and Resources |
|
@@ -13,7 +13,7 @@ module SnippetCli
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def execute(input: $stdin, output: $stdout)
|
16
|
-
|
16
|
+
def show_banner()
|
17
17
|
box = TTY::Box::frame(width:67, height:11, border: :thick, align: :left) do
|
18
18
|
"
|
19
19
|
##### # # ### ###### ###### ####### #######
|
@@ -28,7 +28,7 @@ module SnippetCli
|
|
28
28
|
puts box
|
29
29
|
end
|
30
30
|
puts show_banner()
|
31
|
-
parsed_markdown=TTY::Markdown.parse_file('
|
31
|
+
parsed_markdown=TTY::Markdown.parse_file('/snippet_cli/commands/info.md')
|
32
32
|
output.puts parsed_markdown
|
33
33
|
end
|
34
34
|
end
|