Class: Boxafe::Program

Inherits:
Commander::Runner
  • Object
show all
Includes:
Commander::UI, Commander::UI::AskForClass
Defined in:
lib/boxafe/program.rb

Constant Summary collapse

GLOBAL_OPTIONS =
[ :config, :verbose ]
BACKTRACE_NOTICE =
' (use --trace to view backtrace)'

Instance Method Summary collapse

Constructor Details

#initialize(argv = ARGV) ⇒ Program

Returns a new instance of Program.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/boxafe/program.rb', line 12

def initialize argv = ARGV
  super argv

  program :name, 'boxafe'
  program :version, Boxafe::VERSION
  program :description, 'Secure your Dropbox with encfs.'

  global_option '-c', '--config PATH', 'Use a custom configuration file (defaults to ~/.boxafe.rb)'
  global_option '--verbose', 'Increase verbosity'

  command :status do |c|
    c.syntax = 'boxafe status'
    c.description = 'Display the current status and configuration'
    c.action do |args,options|
      to_trace_or_not_to_trace options.trace do
        cli.status extract(options)
      end
    end
  end

  command :mount do |c|
    c.syntax = 'boxafe mount'
    c.description = 'Mount configured boxes with EncFS'
    c.action do |args,options|
      to_trace_or_not_to_trace options.trace do
        cli.mount *args
      end
    end
  end

  command :unmount do |c|
    c.syntax = 'boxafe unmount'
    c.description = 'Unmount configured boxes'
    c.action do |args,options|
      to_trace_or_not_to_trace options.trace do
        cli.unmount *args
      end
    end
  end

  command :start do |c|
    c.syntax = 'boxafe start'
    c.description = 'Configure boxafe to run on startup'
    c.action do |args,options|
      to_trace_or_not_to_trace options.trace do
        cli.start *(args.push extract(options))
      end
    end
  end

  command :stop do |c|
    c.syntax = 'boxafe stop'
    c.description = 'Stop boxafe from running on startup'
    c.action do |args,options|
      to_trace_or_not_to_trace options.trace do
        cli.stop *(args.push extract(options))
      end
    end
  end

  default_command :status
end