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.
- checksums.yaml +4 -4
- data/README.md +32 -19
- 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: e7c51635053eb1a1e97fa5b9ad67882501388597a1c1254a3cdd07826de4de0c
|
|
4
|
+
data.tar.gz: b19017147fb580390f31cf210bfb5ee451845a2e908a5c610d9b4a44b1013f9a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0f1ecfa2e48a464eed2fdc316d3e8f56fa41942b3d3b8297738850f063c4809d1c7da3243f8d8401fc8c9a9cd8e9a0e2656c043e59d4de9dd8a17a46075e0953
|
|
7
|
+
data.tar.gz: d2562942691900f803d7f78f8c0f4e5fe4935c12f9f0c6fae954cdd4462ea0ee856fafb609596b73ef0e9302353e70661010df9d1e5dd2595b1b1e2b1e81d7ba
|
data/README.md
CHANGED
|
@@ -1,24 +1,13 @@
|
|
|
1
|
-
#
|
|
1
|
+
# snippet_cli
|
|
2
|
+
[](https://badge.fury.io/rb/snippet_cli)
|
|
2
3
|
|
|
3
|
-
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
```ruby
|
|
12
|
-
gem 'snippet_cli'
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
And then execute:
|
|
8
|
+
Install it using command:
|
|
16
9
|
|
|
17
|
-
$
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
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
|