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.
- checksums.yaml +4 -4
- data/README.md +29 -15
- data/exe/snippet_cli +45 -11
- data/lib/snippet_cli/Espanso_Merged_Matchfile_Schema.json +889 -0
- data/lib/snippet_cli/banner.rb +16 -0
- data/lib/snippet_cli/commands/check.rb +49 -0
- data/lib/snippet_cli/commands/conflict.rb +75 -0
- data/lib/snippet_cli/commands/new.rb +16 -102
- data/lib/snippet_cli/commands/vars.rb +58 -0
- data/lib/snippet_cli/commands/version.rb +17 -0
- data/lib/snippet_cli/conflict_detector.rb +71 -0
- data/lib/snippet_cli/cursor_helper.rb +20 -0
- data/lib/snippet_cli/espanso_config.rb +26 -0
- data/lib/snippet_cli/file_helper.rb +16 -0
- data/lib/snippet_cli/file_validator.rb +33 -0
- data/lib/snippet_cli/file_writer.rb +12 -0
- data/lib/snippet_cli/form_field_parser.rb +13 -0
- data/lib/snippet_cli/global_vars_formatter.rb +63 -0
- data/lib/snippet_cli/global_vars_writer.rb +29 -0
- data/lib/snippet_cli/gum_theme.rb +39 -0
- data/lib/snippet_cli/hash_utils.rb +21 -0
- data/lib/snippet_cli/match_file_writer.rb +26 -0
- data/lib/snippet_cli/match_validator.rb +33 -0
- data/lib/snippet_cli/new_workflow.rb +98 -0
- data/lib/snippet_cli/replacement_text_collector.rb +55 -0
- data/lib/snippet_cli/replacement_validator.rb +35 -0
- data/lib/snippet_cli/replacement_wizard.rb +100 -0
- data/lib/snippet_cli/schema_validator.rb +27 -0
- data/lib/snippet_cli/snippet_builder.rb +133 -0
- data/lib/snippet_cli/string_helper.rb +11 -0
- data/lib/snippet_cli/table_formatter.rb +37 -0
- data/lib/snippet_cli/trigger_resolver.rb +67 -0
- data/lib/snippet_cli/ui.rb +90 -0
- data/lib/snippet_cli/var_builder/form_fields.rb +54 -0
- data/lib/snippet_cli/var_builder/name_collector.rb +69 -0
- data/lib/snippet_cli/var_builder/param_schema.rb +71 -0
- data/lib/snippet_cli/var_builder/params.rb +127 -0
- data/lib/snippet_cli/var_builder.rb +125 -0
- data/lib/snippet_cli/var_summary_renderer.rb +48 -0
- data/lib/snippet_cli/var_usage_checker.rb +48 -0
- data/lib/snippet_cli/var_yaml_renderer.rb +20 -0
- data/lib/snippet_cli/vars_block_renderer.rb +15 -0
- data/lib/snippet_cli/version.rb +3 -1
- data/lib/snippet_cli/wizard_context.rb +13 -0
- data/lib/snippet_cli/wizard_helpers/error_handler.rb +20 -0
- data/lib/snippet_cli/wizard_helpers/match_file_selector.rb +32 -0
- data/lib/snippet_cli/wizard_helpers/prompt_helpers.rb +57 -0
- data/lib/snippet_cli/wizard_helpers/validation_loop.rb +33 -0
- data/lib/snippet_cli/wizard_helpers.rb +8 -0
- data/lib/snippet_cli/yaml_line_resolver.rb +46 -0
- data/lib/snippet_cli/yaml_loader.rb +19 -0
- data/lib/snippet_cli/yaml_param_renderer.rb +33 -0
- data/lib/snippet_cli/yaml_scalar.rb +48 -0
- data/lib/snippet_cli.rb +44 -1
- metadata +134 -101
- data/.gitignore +0 -11
- data/.rspec +0 -3
- data/.travis.yml +0 -9
- data/CODE_OF_CONDUCT.md +0 -74
- data/Gemfile +0 -17
- data/Rakefile +0 -10
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/lib/Setup.rb +0 -76
- data/lib/banner.rb +0 -16
- data/lib/snippet_cli/cli.rb +0 -62
- data/lib/snippet_cli/command.rb +0 -121
- data/lib/snippet_cli/commands/info.md +0 -20
- data/lib/snippet_cli/commands/info.rb +0 -36
- data/lib/snippet_cli/commands/setup.rb +0 -108
- data/lib/snippet_cli/templates/.gitkeep +0 -1
- data/lib/snippet_cli/templates/config/.gitkeep +0 -1
- data/lib/snippet_cli/templates/create/.gitkeep +0 -1
- data/lib/snippet_cli/templates/info/.gitkeep +0 -1
- data/lib/snippet_cli/templates/setup/.gitkeep +0 -1
- data/lib/snippet_generator.rb +0 -85
- 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 +0 -37
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 84303594a4521d8a9a93283732affcdc8832b7ae4483e1f9aa1af219003d35be
|
|
4
|
+
data.tar.gz: ba13a8233cf612c716432f0fcdb98157b286c9790686dc46f739708c1ebec91c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
9
|
+
Install it using command:
|
|
10
10
|
|
|
11
|
-
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
5
|
-
$:.unshift(lib_path) if !$:.include?(lib_path)
|
|
6
|
-
require 'snippet_cli/cli'
|
|
4
|
+
$LOAD_PATH.unshift(File.join(__dir__, '..', 'lib'))
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
exit(1)
|
|
11
|
-
end
|
|
6
|
+
require 'snippet_cli/gum_theme'
|
|
7
|
+
SnippetCli::GumTheme.apply!
|
|
12
8
|
|
|
13
9
|
begin
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|