Class: Pastejour::Cli

Inherits:
Object
  • Object
show all
Defined in:
lib/pastejour/cli.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(out, args) ⇒ Cli

Returns a new instance of Cli.



8
9
10
11
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
# File 'lib/pastejour/cli.rb', line 8

def initialize out, args
  @list     = false
  @multiple = false
  @run      = true
  @tee      = false
  @verbose  = false

  OptionParser.new do |opts|
    opts.separator ""

    opts.on "--list", "-l", "List available pastes." do
      @list = true
    end

    opts.on "--help", "-h", "-?", "Show this help." do
      out.puts opts
      @run = false
    end

    opts.on "--multiple", "-m", "Allow multiple slurps when pasting." do
      @multiple = true
    end

    opts.on "--tee", "-t", "Tee to STDOUT when pasting." do
      @tee = true
    end

    opts.on "--version", "-V", "Prints #{Pastejour::VERSION}." do
      out.puts Pastejour::VERSION
      @run = false
    end

    opts.separator ""
    opts.parse! args

    @name = args.shift

    yield self if @run && block_given?
  end
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/pastejour/cli.rb', line 6

def name
  @name
end

Instance Method Details

#list?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/pastejour/cli.rb', line 49

def list?
  @list
end

#multiple?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/pastejour/cli.rb', line 53

def multiple?
  @multiple
end

#run?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/pastejour/cli.rb', line 57

def run?
  @run
end

#tee?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/pastejour/cli.rb', line 61

def tee?
  @tee
end

#verbose?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/pastejour/cli.rb', line 65

def verbose?
  @verbose
end