Sha256: a015afedc7fbebc8ba819afec2e928e733b3b0ef90439478f088f32d6d482fb7

Contents?: true

Size: 1.76 KB

Versions: 1

Compression:

Stored size: 1.76 KB

Contents

#!/usr/bin/env ruby

$:.unshift(File.dirname(__FILE__) + '/../lib')

require 'revenc'
require 'optparse'
require 'term/ansicolor'

available_actions = Revenc::AVAILABLE_ACTIONS

banner = <<BANNER
Revenc is an EncFS helper

  Usage: revenc action [options]
BANNER
banner << "\nActions: #{available_actions.join(' ')}\n" unless available_actions.empty?

help = banner
help += <<HELP
  Mount: revenc mount <unencrypted source> <empty mountpoint>
Unmount: revenc unmount <mounted encypted folder> 
   Copy: revenc copy <encrypted source>  <destination>
         Note: Copying is normally done via rsync

Options:
 
HELP

options = {}
OptionParser.new do |opts|
  opts.banner = help

  # set defaults
  options[:verbose] = false
  options[:coloring] = true

  opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
    options[:verbose] = v
  end

  opts.on("-c", "--[no-]coloring", "Ansi color in output") do |c|
    options[:coloring] = c
  end

  opts.on("--version", "Display current version") do
    puts "revenc, version " + Revenc.version
    exit 0
  end

  opts.on("-d", "--dry-run", "Run action but omit the final execute step.  Useful combined with --verbose") do |d|
    options[:dry_run] = d
  end

  opts.on("--config FILE", "Load configuration options from FILE") do |file|
    options[:config] = file 
  end

  # no argument, shows at tail.  This will print an options summary.
  opts.on_tail("-h", "--help", "Show this message") do
    puts opts
    exit 0
  end
  
  begin
    opts.parse!
  rescue OptionParser::InvalidOption => e
    puts "revenc #{e}"
    puts "revenc --help for more information"
    exit 1
  end

end

if STDOUT.isatty
  Term::ANSIColor::coloring = options[:coloring]
else
  Term::ANSIColor::coloring = false
end

app = Revenc::App.new(FileUtils.pwd, options)
app.run

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
revenc-0.1.3 bin/revenc