Commit e22bdfb

mo khan <mo@mokhan.ca>
2021-02-06 23:58:57
feat: add support to exec commands from jive.yml
1 parent c383293
Changed files (2)
lib/jive/cli.rb
@@ -1,8 +1,10 @@
 # frozen_string_literal: true
 
+require "pathname"
 require "thor"
+require "yaml"
+
 require "jive"
-require "pathname"
 
 module Jive
   module Cli
@@ -25,6 +27,23 @@ module Jive
         end
       end
 
+      desc "exec <command>", "run command from jive.yml"
+      def exec(command)
+        path = Pathname.pwd.join("jive.yml")
+        if path.exist?
+          runner.run_safely do
+            runner.execute(
+              YAML
+              .safe_load(path.read)
+              .dig("commands", command)
+            )
+          end
+        else
+          say "Error: jive.yml not found"
+          exit 2
+        end
+      end
+
       desc "setup", "provide instructions to integrate into shell"
       def setup
         say <<~MESSAGE
jive.yml
@@ -0,0 +1,5 @@
+---
+commands:
+  autofix: ./bin/style -A
+  style: ./bin/style
+  test: ./bin/test