Class: Pastejour::Cli
- Inherits:
-
Object
- Object
- Pastejour::Cli
- Defined in:
- lib/pastejour/cli.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(out, args) ⇒ Cli
constructor
A new instance of Cli.
- #list? ⇒ Boolean
- #multiple? ⇒ Boolean
- #run? ⇒ Boolean
- #tee? ⇒ Boolean
- #verbose? ⇒ Boolean
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 |
# 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.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.parse! args @name = args.shift yield self if @run && block_given? end end |
Instance Attribute Details
#name ⇒ Object (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
46 47 48 |
# File 'lib/pastejour/cli.rb', line 46 def list? @list end |
#multiple? ⇒ Boolean
50 51 52 |
# File 'lib/pastejour/cli.rb', line 50 def multiple? @multiple end |
#run? ⇒ Boolean
54 55 56 |
# File 'lib/pastejour/cli.rb', line 54 def run? @run end |
#tee? ⇒ Boolean
58 59 60 |
# File 'lib/pastejour/cli.rb', line 58 def tee? @tee end |
#verbose? ⇒ Boolean
62 63 64 |
# File 'lib/pastejour/cli.rb', line 62 def verbose? @verbose end |