 
     fw = Path.join(File.cwd!, "_images/#{target}/#{otp_app}.fw")
     unless File.exists?(fw) do
-      raise "Firmware for target #{target} not found at #{fw} run `mix firmware` to build"
+      Mix.raise "Firmware for target #{target} not found at #{fw} run `mix firmware` to build"
     end
 
-    args = ["-a", "-i", fw, "-t", "complete"] ++ argv
+    dev =
+      case opts[:device] do
+        nil -> prompt_dev()
+        dev -> dev
+      end
+    burn(fw, dev, opts, argv)
+  end
+
+  defp burn(fw, dev, opts, argv) do
+    task = opts[:task] || "complete"
+    args = ["-a", "-i", fw, "-t", task, "-d", dev] ++ argv
     {cmd, args} =
       case :os.type do
         {_, :darwin} ->

      end
    shell(cmd, args)
  end
end

  use Mix.Task
  import Mix.Nerves.Utils

  @switches [device: :string, task: :string]
  @aliases [d: :device, t: :task]

  def run(argv) do
    preflight

    {opts, argv, _} = OptionParser.parse(argv, switches: @switches, aliases: @aliases)

    Mix.shell.info "Nerves Firmware Burn"
    config = Mix.Project.config
