snippet_cli 0.3.6 → 0.5.2

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 +29 -15
  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: 84303594a4521d8a9a93283732affcdc8832b7ae4483e1f9aa1af219003d35be
4
+ data.tar.gz: ba13a8233cf612c716432f0fcdb98157b286c9790686dc46f739708c1ebec91c
5
5
  SHA512:
6
- metadata.gz: df7918fc45a58b683e9a39dbeacb5b7d55ce7ab360d6885d6ae5b942ed8b74b3c09a95dcd525b6819dff7560a3170f9122cd48ad2ce6aef43de30470351ac23f
7
- data.tar.gz: 92fe9fef37c4ac6224f97bfaf72a61d10076bc2f64e91a319b9fc67a0798dc00947712f2bc59dfb257d10885ffed3bdf0fbc82fee724947ed7885a73bdcdab1c
6
+ metadata.gz: d6a70bb1ea3bb681793ae54066af65a143b345cc0ca446a57012e6e562a21816b01c38e8d7ec3188c59c50484ee376fa09b225df6e2feb9b47fefcfca5dabc76
7
+ data.tar.gz: 47ea2519a20ce680dc1d2ef5c1d1e4473e013fce48a4bf6ca14e62bc6f6293eedd8fa533a97dc389717e5600d832c8781fbedf31c14259befcc5281bcc667793
data/README.md CHANGED
@@ -6,19 +6,9 @@ TODO: Delete this and the text above, and describe your gem
6
6
 
7
7
  ## Installation
8
8
 
9
- Add this line to your application's Gemfile:
9
+ Install it using command:
10
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
11
+ $ sudo gem install snippet_cli
22
12
 
23
13
  ## Usage
24
14
 
@@ -26,9 +16,33 @@ TODO: Write usage instructions here
26
16
 
27
17
  ## Development
28
18
 
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).
19
+ This project uses [devenv](https://devenv.sh) (Nix-based) for environment management. Do not use rbenv, rvm, asdf, or Homebrew Ruby.
20
+
21
+ ### First-time setup
22
+
23
+ 1. [Install Nix](https://nixos.org/download) and [devenv](https://devenv.sh/getting-started/)
24
+ 2. Clone the repo:
25
+ ```bash
26
+ git clone https://github.com/ajmarkow/snippet_cli.git
27
+ cd snippet_cli
28
+ ```
29
+ 3. Enter the development environment:
30
+ ```bash
31
+ devenv shell
32
+ ```
33
+ 4. Install dependencies:
34
+ ```bash
35
+ bundle install
36
+ ```
37
+ 5. Run the tests to verify everything works:
38
+ ```bash
39
+ bundle exec rake spec
40
+ ```
41
+
42
+ ### Releasing a new version
43
+
44
+ 1. Update the version number in `lib/snippet_cli/version.rb`
45
+ 2. Commit with the message containing `gem-release-ready` — CI will build and push the gem to RubyGems automatically once tests pass
32
46
 
33
47
  ## Contributing
34
48
 
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