snippet_cli 0.3.6 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +32 -19
  3. data/exe/snippet_cli +45 -11
  4. data/lib/snippet_cli/Espanso_Merged_Matchfile_Schema.json +889 -0
  5. data/lib/snippet_cli/banner.rb +16 -0
  6. data/lib/snippet_cli/commands/check.rb +49 -0
  7. data/lib/snippet_cli/commands/conflict.rb +75 -0
  8. data/lib/snippet_cli/commands/new.rb +16 -102
  9. data/lib/snippet_cli/commands/vars.rb +58 -0
  10. data/lib/snippet_cli/commands/version.rb +17 -0
  11. data/lib/snippet_cli/conflict_detector.rb +71 -0
  12. data/lib/snippet_cli/cursor_helper.rb +20 -0
  13. data/lib/snippet_cli/espanso_config.rb +26 -0
  14. data/lib/snippet_cli/file_helper.rb +16 -0
  15. data/lib/snippet_cli/file_validator.rb +33 -0
  16. data/lib/snippet_cli/file_writer.rb +12 -0
  17. data/lib/snippet_cli/form_field_parser.rb +13 -0
  18. data/lib/snippet_cli/global_vars_formatter.rb +63 -0
  19. data/lib/snippet_cli/global_vars_writer.rb +29 -0
  20. data/lib/snippet_cli/gum_theme.rb +39 -0
  21. data/lib/snippet_cli/hash_utils.rb +21 -0
  22. data/lib/snippet_cli/match_file_writer.rb +26 -0
  23. data/lib/snippet_cli/match_validator.rb +33 -0
  24. data/lib/snippet_cli/new_workflow.rb +98 -0
  25. data/lib/snippet_cli/replacement_text_collector.rb +55 -0
  26. data/lib/snippet_cli/replacement_validator.rb +35 -0
  27. data/lib/snippet_cli/replacement_wizard.rb +100 -0
  28. data/lib/snippet_cli/schema_validator.rb +27 -0
  29. data/lib/snippet_cli/snippet_builder.rb +133 -0
  30. data/lib/snippet_cli/string_helper.rb +11 -0
  31. data/lib/snippet_cli/table_formatter.rb +37 -0
  32. data/lib/snippet_cli/trigger_resolver.rb +67 -0
  33. data/lib/snippet_cli/ui.rb +90 -0
  34. data/lib/snippet_cli/var_builder/form_fields.rb +54 -0
  35. data/lib/snippet_cli/var_builder/name_collector.rb +69 -0
  36. data/lib/snippet_cli/var_builder/param_schema.rb +71 -0
  37. data/lib/snippet_cli/var_builder/params.rb +127 -0
  38. data/lib/snippet_cli/var_builder.rb +125 -0
  39. data/lib/snippet_cli/var_summary_renderer.rb +48 -0
  40. data/lib/snippet_cli/var_usage_checker.rb +48 -0
  41. data/lib/snippet_cli/var_yaml_renderer.rb +20 -0
  42. data/lib/snippet_cli/vars_block_renderer.rb +15 -0
  43. data/lib/snippet_cli/version.rb +3 -1
  44. data/lib/snippet_cli/wizard_context.rb +13 -0
  45. data/lib/snippet_cli/wizard_helpers/error_handler.rb +20 -0
  46. data/lib/snippet_cli/wizard_helpers/match_file_selector.rb +32 -0
  47. data/lib/snippet_cli/wizard_helpers/prompt_helpers.rb +57 -0
  48. data/lib/snippet_cli/wizard_helpers/validation_loop.rb +33 -0
  49. data/lib/snippet_cli/wizard_helpers.rb +8 -0
  50. data/lib/snippet_cli/yaml_line_resolver.rb +46 -0
  51. data/lib/snippet_cli/yaml_loader.rb +19 -0
  52. data/lib/snippet_cli/yaml_param_renderer.rb +33 -0
  53. data/lib/snippet_cli/yaml_scalar.rb +48 -0
  54. data/lib/snippet_cli.rb +44 -1
  55. metadata +134 -101
  56. data/.gitignore +0 -11
  57. data/.rspec +0 -3
  58. data/.travis.yml +0 -9
  59. data/CODE_OF_CONDUCT.md +0 -74
  60. data/Gemfile +0 -17
  61. data/Rakefile +0 -10
  62. data/bin/console +0 -14
  63. data/bin/setup +0 -8
  64. data/lib/Setup.rb +0 -76
  65. data/lib/banner.rb +0 -16
  66. data/lib/snippet_cli/cli.rb +0 -62
  67. data/lib/snippet_cli/command.rb +0 -121
  68. data/lib/snippet_cli/commands/info.md +0 -20
  69. data/lib/snippet_cli/commands/info.rb +0 -36
  70. data/lib/snippet_cli/commands/setup.rb +0 -108
  71. data/lib/snippet_cli/templates/.gitkeep +0 -1
  72. data/lib/snippet_cli/templates/config/.gitkeep +0 -1
  73. data/lib/snippet_cli/templates/create/.gitkeep +0 -1
  74. data/lib/snippet_cli/templates/info/.gitkeep +0 -1
  75. data/lib/snippet_cli/templates/setup/.gitkeep +0 -1
  76. data/lib/snippet_generator.rb +0 -85
  77. data/snippet_cli-0.1.0.gem +0 -0
  78. data/snippet_cli-0.1.1.gem +0 -0
  79. data/snippet_cli-0.1.2.gem +0 -0
  80. data/snippet_cli-0.1.3.gem +0 -0
  81. data/snippet_cli-0.1.4.gem +0 -0
  82. data/snippet_cli-0.1.5.gem +0 -0
  83. data/snippet_cli-0.1.6.gem +0 -0
  84. data/snippet_cli-0.1.7.gem +0 -0
  85. data/snippet_cli-0.1.8.gem +0 -0
  86. data/snippet_cli-0.1.9.gem +0 -0
  87. data/snippet_cli-0.2.0.gem +0 -0
  88. data/snippet_cli-0.2.1.gem +0 -0
  89. data/snippet_cli-0.2.2.gem +0 -0
  90. data/snippet_cli-0.2.3.gem +0 -0
  91. data/snippet_cli-0.2.4.gem +0 -0
  92. data/snippet_cli-0.2.6.gem +0 -0
  93. data/snippet_cli-0.2.7.gem +0 -0
  94. data/snippet_cli-0.2.8.gem +0 -0
  95. data/snippet_cli.gemspec +0 -37
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9e25141ab39fae936abcf0a874788babb6c1221d7ca3b9f7c825b9f8509e5838
4
- data.tar.gz: e7349f468d60d572ea3f996f9c8840e36e00912e73d5554a5cbf115689eed275
3
+ metadata.gz: e7c51635053eb1a1e97fa5b9ad67882501388597a1c1254a3cdd07826de4de0c
4
+ data.tar.gz: b19017147fb580390f31cf210bfb5ee451845a2e908a5c610d9b4a44b1013f9a
5
5
  SHA512:
6
- metadata.gz: df7918fc45a58b683e9a39dbeacb5b7d55ce7ab360d6885d6ae5b942ed8b74b3c09a95dcd525b6819dff7560a3170f9122cd48ad2ce6aef43de30470351ac23f
7
- data.tar.gz: 92fe9fef37c4ac6224f97bfaf72a61d10076bc2f64e91a319b9fc67a0798dc00947712f2bc59dfb257d10885ffed3bdf0fbc82fee724947ed7885a73bdcdab1c
6
+ metadata.gz: 0f1ecfa2e48a464eed2fdc316d3e8f56fa41942b3d3b8297738850f063c4809d1c7da3243f8d8401fc8c9a9cd8e9a0e2656c043e59d4de9dd8a17a46075e0953
7
+ data.tar.gz: d2562942691900f803d7f78f8c0f4e5fe4935c12f9f0c6fae954cdd4462ea0ee856fafb609596b73ef0e9302353e70661010df9d1e5dd2595b1b1e2b1e81d7ba
data/README.md CHANGED
@@ -1,24 +1,13 @@
1
- # SnippetCli
1
+ # snippet_cli
2
+ [![Gem Version](https://badge.fury.io/rb/snippet_cli.svg)](https://badge.fury.io/rb/snippet_cli)
2
3
 
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
4
+ snippet_cli is a gem for generating valid yaml configurations for snippets for the program Espanso. Additionally, it includes a few espanso related utilities, like commands to check your matchfile for validity against the Espanso schema, or for conflicting triggers in your matchfile.
6
5
 
7
6
  ## Installation
8
7
 
9
- Add this line to your application's Gemfile:
10
-
11
- ```ruby
12
- gem 'snippet_cli'
13
- ```
14
-
15
- And then execute:
8
+ Install it using command:
16
9
 
17
- $ bundle install
18
-
19
- Or install it yourself as:
20
-
21
- $ gem install snippet_cli
10
+ $ sudo gem install snippet_cli
22
11
 
23
12
  ## Usage
24
13
 
@@ -26,9 +15,33 @@ TODO: Write usage instructions here
26
15
 
27
16
  ## Development
28
17
 
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).
18
+ This project uses [devenv](https://devenv.sh) (Nix-based) for environment management.
19
+
20
+ ### First-time setup
21
+
22
+ 1. [Install Nix](https://nixos.org/download) and [devenv](https://devenv.sh/getting-started/)
23
+ 2. Clone the repo:
24
+ ```bash
25
+ git clone https://github.com/ajmarkow/snippet_cli.git
26
+ cd snippet_cli
27
+ ```
28
+ 3. Enter the development environment:
29
+ ```bash
30
+ devenv shell
31
+ ```
32
+ 4. Install dependencies:
33
+ ```bash
34
+ bundle install
35
+ ```
36
+ 5. Run the tests to verify everything works:
37
+ ```bash
38
+ bundle exec rake spec
39
+ ```
40
+
41
+ ### Releasing a new version
42
+
43
+ 1. Update the version number in `lib/snippet_cli/version.rb`
44
+ 2. Commit with the message containing `gem-release-ready` — CI will build and push the gem to RubyGems automatically once tests pass
32
45
 
33
46
  ## Contributing
34
47
 
data/exe/snippet_cli CHANGED
@@ -1,18 +1,52 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- lib_path = File.expand_path('../lib', __dir__)
5
- $:.unshift(lib_path) if !$:.include?(lib_path)
6
- require 'snippet_cli/cli'
4
+ $LOAD_PATH.unshift(File.join(__dir__, '..', 'lib'))
7
5
 
8
- Signal.trap('INT') do
9
- warn("\n#{caller.join("\n")}: interrupted")
10
- exit(1)
11
- end
6
+ require 'snippet_cli/gum_theme'
7
+ SnippetCli::GumTheme.apply!
12
8
 
13
9
  begin
14
- SnippetCli::CLI.start
15
- rescue SnippetCli::CLI::Error => err
16
- puts "ERROR: #{err.message}"
17
- exit 1
10
+ require 'snippet_cli'
11
+ require 'snippet_cli/banner'
12
+
13
+ # When stdout is piped, redirect UI to the terminal so it displays normally.
14
+ # The original stdout is saved for structured output (YAML) only.
15
+ # Skip redirect when SNIPPET_CLI_NO_REDIRECT is set (used by integration tests).
16
+ unless $stdout.tty? || ENV['SNIPPET_CLI_NO_REDIRECT']
17
+ SnippetCli.pipe_output = $stdout.dup
18
+ begin
19
+ $stdout.reopen('/dev/tty', 'w')
20
+ rescue Errno::ENXIO, Errno::ENOENT
21
+ # No controlling terminal (CI, cron, etc.) — fall back to stderr
22
+ $stdout.reopen($stderr)
23
+ end
24
+ end
25
+
26
+ puts SnippetCli.banner
27
+ puts
28
+
29
+ require 'stringio'
30
+ cli_err = StringIO.new
31
+ begin
32
+ Dry::CLI.new(SnippetCli::CLI).call(err: cli_err)
33
+ rescue SystemExit => e
34
+ cli_error_output = cli_err.string.strip
35
+ unless cli_error_output.empty?
36
+ if cli_error_output.start_with?('ERROR:')
37
+ SnippetCli::UI.error(cli_error_output.sub(/\AERROR:\s*/, ''))
38
+ else
39
+ puts cli_error_output
40
+ end
41
+ end
42
+ exit e.status
43
+ end
44
+ rescue Interrupt
45
+ if defined?(SnippetCli::UI)
46
+ puts
47
+ SnippetCli::UI.error('Interrupted, exiting snippet_cli.')
48
+ else
49
+ warn "\nInterrupted."
50
+ end
51
+ exit 130
18
52
  end