From f6de3ae7dcbe704707a523b2156225c47ffa3c6b Mon Sep 17 00:00:00 2001 From: Miles Georgi Date: Thu, 12 Sep 2024 21:08:29 -0700 Subject: [PATCH] Make use of CommandConnector --- CHANGELOG.md | 4 ++++ Gemfile.lock | 44 +++++++++++++++++++++++--------------------- bin/extract-repo | 11 ++++++++--- extract-repo.gemspec | 1 + lib/extract_repo.rb | 4 +++- 5 files changed, 39 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a2ba59e..2ebcf28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [unreleased] + +- Make use of CommandConnector + ## [0.0.2] - 2024-08-25 - Include extract-repo executable diff --git a/Gemfile.lock b/Gemfile.lock index 1bfce69..045bab8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -3,6 +3,7 @@ PATH specs: extract-repo (0.0.2) foobara + foobara-sh-cli-connector GEM remote: https://rubygems.org/ @@ -10,6 +11,7 @@ GEM addressable (2.8.7) public_suffix (>= 2.0.2, < 7.0) ast (2.4.2) + base64 (0.2.0) bigdecimal (3.1.8) byebug (11.1.3) coderay (1.1.3) @@ -17,13 +19,15 @@ GEM bigdecimal rexml diff-lcs (1.5.1) - docile (1.4.0) + docile (1.4.1) ffi (1.17.0-x86_64-linux-gnu) - foobara (0.0.2) + foobara (0.0.9) foobara-util - foobara-rubocop-rules (0.0.3) + foobara-rubocop-rules (0.0.4) rubocop rubocop-rspec + foobara-sh-cli-connector (0.0.3) + foobara foobara-spec-helpers (0.0.3) foobara-util foobara-util (0.0.4) @@ -42,7 +46,7 @@ GEM guard (~> 2.1) guard-compat (~> 1.1) rspec (>= 2.99.0, < 4.0) - hashdiff (1.1.0) + hashdiff (1.1.1) json (2.7.2) language_server-protocol (3.17.0.3) listen (3.9.0) @@ -54,8 +58,8 @@ GEM notiffany (0.1.3) nenv (~> 0.1) shellany (~> 0.0) - parallel (1.25.1) - parser (3.3.4.0) + parallel (1.26.3) + parser (3.3.5.0) ast (~> 2.4.1) racc pry (0.14.2) @@ -64,23 +68,22 @@ GEM pry-byebug (3.10.1) byebug (~> 11.0) pry (>= 0.13, < 0.15) - public_suffix (6.0.0) - racc (1.8.0) + public_suffix (6.0.1) + racc (1.8.1) rainbow (3.1.1) rake (13.2.1) rb-fsevent (0.11.2) rb-inotify (0.11.1) ffi (~> 1.0) regexp_parser (2.9.2) - rexml (3.3.2) - strscan + rexml (3.3.7) rspec (3.13.0) rspec-core (~> 3.13.0) rspec-expectations (~> 3.13.0) rspec-mocks (~> 3.13.0) - rspec-core (3.13.0) + rspec-core (3.13.1) rspec-support (~> 3.13.0) - rspec-expectations (3.13.1) + rspec-expectations (3.13.3) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) rspec-its (1.3.0) @@ -90,22 +93,21 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) rspec-support (3.13.1) - rubocop (1.65.0) + rubocop (1.66.1) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 2.4, < 3.0) - rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.31.1, < 2.0) + rubocop-ast (>= 1.32.2, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.31.3) + rubocop-ast (1.32.3) parser (>= 3.3.1.0) rubocop-rake (0.6.0) rubocop (~> 1.0) - rubocop-rspec (3.0.3) + rubocop-rspec (3.0.5) rubocop (~> 1.61) ruby-prof (1.7.0) ruby-progressbar (1.13.0) @@ -114,12 +116,12 @@ GEM docile (~> 1.1) simplecov-html (~> 0.11) simplecov_json_formatter (~> 0.1) - simplecov-html (0.12.3) + simplecov-html (0.13.1) simplecov_json_formatter (0.1.4) - strscan (3.1.0) - thor (1.3.1) + thor (1.3.2) unicode-display_width (2.5.0) - vcr (6.2.0) + vcr (6.3.1) + base64 webmock (3.23.1) addressable (>= 2.8.0) crack (>= 0.3.2) diff --git a/bin/extract-repo b/bin/extract-repo index faa4d6b..8c120a7 100755 --- a/bin/extract-repo +++ b/bin/extract-repo @@ -1,6 +1,11 @@ #!/usr/bin/env ruby -require_relative "../lib/extract_repo" +require_relative "../boot" -repo_url, *paths = ARGV -ExtractRepo.run!(repo_url:, paths:) +require "foobara/sh_cli_connector" + +command_connector = Foobara::CommandConnectors::ShCliConnector.new(single_command_mode: true) + +command_connector.connect(ExtractRepo) + +command_connector.run(ARGV) diff --git a/extract-repo.gemspec b/extract-repo.gemspec index 83cd0ec..8057213 100644 --- a/extract-repo.gemspec +++ b/extract-repo.gemspec @@ -32,6 +32,7 @@ Gem::Specification.new do |spec| spec.executables = ["extract-repo"] spec.add_dependency "foobara" + spec.add_dependency "foobara-sh-cli-connector" spec.require_paths = ["lib"] spec.metadata["rubygems_mfa_required"] = "true" diff --git a/lib/extract_repo.rb b/lib/extract_repo.rb index 72abb01..45f7203 100644 --- a/lib/extract_repo.rb +++ b/lib/extract_repo.rb @@ -2,11 +2,13 @@ require "English" require "foobara/all" +# TODO: allow extracting from a local repo and default to that repo as "." class ExtractRepo < Foobara::Command inputs do repo_url :string, :required paths [:string], :required - output_path :string, default: "/#{Dir.home}/tmp/extract" + output_path :string, default: "#{Dir.home}/tmp/extract" + delete_extracted :boolean, default: true end attr_accessor :file_paths