Skip to content

Commit

Permalink
WIP on arduino cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
Edgar O Silva committed Mar 18, 2014
1 parent 9e76193 commit ef4d47d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions ext/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ task :default => :install_commands
task :install_commands do
@install = Artoo::Commands::Install.new
@install.command(File.expand_path(File.dirname(__FILE__) + "/../lib/artoo/commands/firmata.rb"))
@install.command(File.expand_path(File.dirname(__FILE__) + "/../lib/artoo/commands/arduino.rb"))
@install.command(File.expand_path(File.dirname(__FILE__) + "/../lib/artoo/commands/hex/StandardFirmata.cpp.hex"))
end
27 changes: 27 additions & 0 deletions lib/artoo/commands/arduino.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require './firmata'

module Artoo
module Commands
class Arduino < Firmata
package_name "arduino"
end
end
end

# We need to register the commands in the main artoo CLI so they
# can be picked up when this command file is required.
# The steps needed to register new CLI commands from outside
# artoo are:
# 1. Related command files need to be copied to the artoo install commands.
# 2. We do this with a rake task that is triggered when the gem is installed
# (see .gemspec file and look for extensions, ext/Rakefile), in the Rakefile
# we defined a new default class that makes use of an artoo helper class/method
# Artoo::Commands::Install helper method '.command'; see ext/Rakefile for details.
# 3. Finally in our main command file (THIS FILE) we open the artoo CLI::Root class to register
# the new commands.
module CLI
class Root
desc "arduino SUBCOMMAND <serial_port>", "Installs avrdude, uploads firmata to the arduino and connects serial to socket"
subcommand "arduino", Artoo::Commands::Arduino
end
end

0 comments on commit ef4d47d

Please sign in to comment.