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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 89f617ffd3a63d8d8440ac35aef6df4063144bbd561ddb290a9102d09e2315cc
4
- data.tar.gz: c3507e3b77cc801b5c8bd1e4f273e2f4694bde4628ec1cc39744fde7e43e698b
3
+ metadata.gz: 8961277f704443a6959fcfe92a396e72724ac2f439aeaea9456f9a803b165e6d
4
+ data.tar.gz: 54241c7cc79cdd9c3fb86588ac55116bdef42053a9adc403d185334cac7989f6
5
5
  SHA512:
6
- metadata.gz: 94640ce4352e4b045b70b794f7381b02939f7bf8cabfc6259b4a791c5ada058beeaf85b82bcf56791a6a325c99f2d1713067874322498d87c3dfb4855a329e87
7
- data.tar.gz: 721919fa1c9901c7447e11eaddd3c615a71f0c089e5a8339f19cb6a1e5a0f4ad14a2f534180431f72c80b9a7e32d566aa39a96005fa6f52223d509983db2c406
6
+ metadata.gz: be4aa64bd286ef6593b3e008321966bebad41a64fb560fcfb2480e1a45ea933190a8e36a2d59c896838b5352d030bcade664cfcf4d6a83b7533083b46ce495b3
7
+ data.tar.gz: 525d825a3d0ba43b4dde72907be85196c54e1ec0d017ca74398721255e51dd14a18ee200657ac86224b4c78df2d2e7ebce96944d517eb9478a31236f9b141966
data/.travis.yml CHANGED
@@ -1,4 +1,7 @@
1
- ---
1
+ os:
2
+ - linux
3
+ - osx
4
+ - windows
2
5
  language: ruby
3
6
  cache: bundler
4
7
  rvm:
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", "~> 12.0"
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 create 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
-
38
- ## Code of Conduct
39
-
40
- 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).
41
-
42
- ## Copyright
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
@@ -4,3 +4,7 @@ require "rspec/core/rake_task"
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
6
  task :default => :spec
7
+
8
+ task :spec do
9
+ sh 'rspec spec'
10
+ end
data/lib/Setup.rb CHANGED
@@ -1,74 +1,74 @@
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 = "$HOME/Library/Preferences/espanso/default.yml"
41
- else config_path.include?("Linux")
42
- return config_path = "$XDG_CONFIG_HOME/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?("./snippet_cli_config.txt") then
66
-
67
- else
68
- File.open("./snippet_cli_config.txt", "a") { |f| f.write "NAME = #{self.user_name}\n"}
69
- File.open("./snippet_cli_config.txt", "a") { |f| f.write "OS = #{self.user_os}\n"}
70
- File.open("./snippet_cli_config.txt", "a") { |f| f.write "STORAGE = #{self.user_storage}\n"}
71
- File.open("./snippet_cli_config.txt", "a") { |f| f.write "CONFIG_PRESENT = TRUE\n"}
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
@@ -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
- # Error raised by this runner
12
- Error = Class.new(StandardError)
13
-
14
- desc 'version', 'snippet_cli version'
15
- def version
16
- require_relative 'version'
17
- puts "v#{SnippetCli::VERSION}"
18
- end
19
- map %w(--version -v) => :version
20
-
21
- desc 'info [DOCS]', 'Show info and docs about using the program.'
22
- method_option :help, aliases: '-h', type: :boolean,
23
- desc: 'Display usage information'
24
- def info(docs = nil)
25
- if options[:help]
26
- invoke :help, ['info']
27
- else
28
- require_relative 'commands/info'
29
- SnippetCli::Commands::Info.new(docs, options).execute
30
- end
31
- end
32
-
33
- desc 'new', 'Guides you through adding a new snippet.'
34
- method_option :help, aliases: '-h', type: :boolean,
35
- desc: 'Display usage information'
36
- def new(*)
37
- if options[:help]
38
- invoke :help, ['new']
39
- else
40
- require_relative 'commands/new'
41
- SnippetCli::Commands::New.new(options).execute
42
- end
43
- end
44
-
45
- desc 'setup', 'Sets up snippet_cli to modify correct.'
46
- method_option :help, aliases: '-h', type: :boolean,
47
- desc: 'Set directory to write to snippet file in'
48
- def setup(*)
49
- if options[:help]
50
- invoke :help, ['setup']
51
- else
52
- require_relative 'commands/setup'
53
- SnippetCli::Commands::Setup.new().execute
54
- end
55
- end
56
-
57
- end
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
- def show_banner()
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('./lib/info.md')
31
+ parsed_markdown=TTY::Markdown.parse_file('/snippet_cli/commands/info.md')
32
32
  output.puts parsed_markdown
33
33
  end
34
34
  end