Sha256: 19c5fac0fb21059ab4ecbe10c8a07869eb7a3592cac23c00b7270532c8c030ec

Contents?: true

Size: 1.79 KB

Versions: 2

Compression:

Stored size: 1.79 KB

Contents

#!/usr/bin/env ruby

require "gli"
require "fileutils"

require_relative "../lib/tlapse"

include GLI::App
include Tlapse

program_desc "Automated time lapse photography via gphoto2"
version Tlapse::VERSION

desc "Determine whether you are ready to start capturing"
command :doctor do |c|
  c.action do |global_options, options, args|
    doctor
  end
end

desc "Capture a single photo, saving it to the current directory"
command :capture do |c|
  c.action do |global_options, options, args|
    capture_single
  end
end

desc "Start a drb server via which photo capturing may be performed remotely"
command :serve do |c|
  c.flag :h, :host,
    desc:          "The hostname on which the server is run",
    default_value: `hostname`.strip,
    arg_name:      "host"

  c.flag :p, :port,
    desc:         "The port on which the server is run",
    default_value: 9000,
    arg_name:      "port"

  c.action do |global_options, options, args|
    server = Tlapse::Server.new(
      host: options[:host],
      port: options[:port]
    )
    puts "Serving on #{server.full_host}"
    server.serve
  end
end


desc "Use ffmpeg to combine all .jpg files in the current directory"
command :compile do |c|

  c.switch :f, :force,
    desc:     "Force overwrite existing output files",
    negatable: false

  c.flag :o, :out,
    desc:          "The desired output filename",
    default_value: "out.mkv",
    arg_name:      "outfile"

  c.action do |global_options, options, args|
    video = Video.new options

    if video.outfile_exists?
      if options[:force]
        FileUtils.rm video.outfile
        puts "Removed file #{video.outfile}"
      else
        raise "#{video.outfile} exists. Use -f to overwrite or " \
          "-o to specify a different output file."
      end
    end
    video.create!
  end
end

exit run(ARGV)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tlapse-0.3.1 bin/tlapse
tlapse-0.3.0 bin/tlapse