foobara-rails-command-connector 0.1.2 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ddbd332170de0585e2aba5977500f2b934959cd17b157f237b2ace5693bb1d29
4
- data.tar.gz: 03f46d1e7f03a7ed47717290068e1d4de1862c1fe13cd5f68cb9772ac5f6e160
3
+ metadata.gz: c82d23ac51a683a323ec7b818c23576bc09d4b5eba02702244e2b283da5d3071
4
+ data.tar.gz: d3ac1925680b0f9e91d27bfe5b1543ec6edf25b89f25321d5bce2dd6ed38d905
5
5
  SHA512:
6
- metadata.gz: 8bb7043f22ab631c8a34815e9d9126c088c075bdbe91774d9354b5f7a87da7104263935b8c85e2f9665ed018fae63292c91de0740d872b1e6e2196fd58e94148
7
- data.tar.gz: 8e086607336df8c0327278c8223463c69c9fa41e223d9dbd3a259f396f6a4180c615766bba85922efe0e9d9472cee9bff24064ee453b10c2f9cd2347fbda1ce2
6
+ metadata.gz: 14d78b832cbe1a1930a6141bfbfc02126077d647a5dc6f22bf33992ccc18bc8233919d76a45ce80aee7ebcd0bef0d63101ece48725187cdbfc409d9b9b482033
7
+ data.tar.gz: 041add2bddd85e3ef0821eb57de88c7e904904027b488d03b8a20b64ac1d15e67c5c292b308269f7e1269286c6bb1e2be7fe7b7d328a57d832020434b4d053f5
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [0.1.3] - 2025-12-18
2
+
3
+ - Automatically create a RailsCommandConnector if one doesn't exist
4
+
1
5
  ## [0.1.2] - 2025-10-29
2
6
 
3
7
  - Provide a way to prevent auto-installing a RailsCommandConnector
data/README.md CHANGED
@@ -1,24 +1,79 @@
1
1
  # Foobara::RailsCommandConnector
2
2
 
3
- TODO:
3
+ A command connector for Foobara that exposes commands via a shell command-line interface (CLI). This connector parses command-line arguments and routes them to Foobara commands, making it easy to build CLI tools from your Foobara commands.
4
4
 
5
5
  ## Installation
6
6
 
7
- TODO
7
+ Add `gem "foobara-rails-command-connector"` to your Gemfile.
8
8
 
9
9
  ## Usage
10
10
 
11
- TODO: Write usage instructions here
11
+ ### Option 1: Use the connector directly from a file in config/initializers
12
+
13
+ ```ruby
14
+ require "foobara/rails_command_connector"
15
+
16
+ connector = Foobara::CommandConnectors::RailsCommandConnector.new
17
+
18
+ connector.connect(CreateCapybara)
19
+ connector.connect(IncrementAge)
20
+ connector.connect(FindCapybara)
21
+ ```
22
+
23
+ ### Option 2: Expose commands using `command` when drawing routes
24
+
25
+ This `command` method just calls `CommandConnector#connect` under the hood. It supports
26
+ the same DSL and all the same features. It just gives a way for commands exposed in this manner to
27
+ live with your non-Foobara routes.
28
+
29
+ A `RailsCommandConnector` will be automatically created if one doesn't exist, so you can simply:
30
+
31
+ ```ruby
32
+ require "foobara/rails/routes"
33
+
34
+ Rails.application.routes.draw do
35
+ command CreateCapybara
36
+ command IncrementAge
37
+ command FindCapybara
38
+ end
39
+ ```
40
+
41
+ If you need to customize the connector (e.g., set a prefix), you can create it manually before using `command`:
42
+
43
+ ```ruby
44
+ require "foobara/rails_command_connector"
45
+ Foobara::CommandConnectors::RailsCommandConnector.new(prefix: ["api"])
46
+ require "foobara/rails/routes"
47
+
48
+ Rails.application.routes.draw do
49
+ command CreateCapybara
50
+ command IncrementAge
51
+ command FindCapybara
52
+ end
53
+ ```
54
+
55
+ Once you have done one of these options, you can view your commands at `/help` and run
56
+ your commands from `/run`. You can then import your commands into other systems using
57
+ the `foobara-remote-imports` gem and pointing it at `/manifest`. You can generate a
58
+ Typescript SDK with `foob g foob g typescript-remote-commands --manifest-url http://localhost:3000/manifest`
59
+ or forms with
60
+ `foob g typescript-react-command-form --manifest-url http://localhost:3000/manifest --command CreateCommand`.
12
61
 
13
62
  ## Development
14
63
 
15
- You can install dependencies with `bundle` and then run the tests and linter with `rake`.
64
+ ### Contributing
65
+
66
+ Filing bug reports or reporting any issues with using this or any foobara gem would be mighty helpful and appreciated!
67
+
68
+ If you would like to help contributing art/code/documentation/whatever please get in touch!
16
69
 
17
- ## Contributing
70
+ ### Contributing code
18
71
 
19
- Bug reports and pull requests are welcome on GitHub
20
- at https://github.com/foobara/rails-command-connector
72
+ You should be able to fork the repo, clone it locally, run `bundle` and then `rake` to run
73
+ the test suite and linter. Make your changes and push them up and open a PR!
74
+ If you need any help, please reach out and we're happy to help!
21
75
 
22
76
  ## Licensing
23
77
 
24
- This project is licensed under the Mozilla Public License Version 2.0. Please see LICENSE.txt for more info.
78
+ foobara-rails-command-connector is licensed under the Mozilla Public License Version 2.0.
79
+ Please see LICENSE.txt for more info.
@@ -1,7 +1,16 @@
1
1
  ActionDispatch::Routing::Mapper.class_eval do
2
- command_connector = Rails.application.config.foobara_command_connector
3
-
4
2
  define_method :command do |*args, **opts, &block|
3
+ command_connector = Rails.application.config.foobara_command_connector
4
+
5
+ unless command_connector
6
+ require "foobara/rails_command_connector"
7
+ command_connector = Foobara::CommandConnectors::RailsCommandConnector.new
8
+ # Ensure the connector is attached to config even if install! was skipped
9
+ # (e.g., if installation was already done by a previous connector)
10
+ # We check again in case install! attached a different instance (shouldn't happen, but safe)
11
+ command_connector.attach_to_rails_application_config! if Rails.application.config.foobara_command_connector.nil?
12
+ end
13
+
5
14
  command_connector.connect(*args, **opts, &block)
6
15
  end
7
16
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foobara-rails-command-connector
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi