Class: Duty::IO::CLI::Input

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

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Input

Returns a new instance of Input.



5
6
7
# File 'lib/duty/io/cli.rb', line 5

def initialize(args)
  @args = [args].flatten
end

Instance Method Details

#[](index) ⇒ Object



9
10
11
# File 'lib/duty/io/cli.rb', line 9

def[](index)
  args[index]
end

#drop(index) ⇒ Object



23
24
25
# File 'lib/duty/io/cli.rb', line 23

def drop(index)
  args.drop(1)
end

#join(seperator = '') ⇒ Object



27
28
29
# File 'lib/duty/io/cli.rb', line 27

def join(seperator='')
  args.join(seperator)
end

#needs_completion?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/duty/io/cli.rb', line 35

def needs_completion?
  args.first == '--cmplt'
end

#needs_help?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/duty/io/cli.rb', line 39

def needs_help?
  args.empty? || args == %w(-h) || args == %w(--help)
end

#task_inputObject



18
19
20
21
# File 'lib/duty/io/cli.rb', line 18

def task_input
  task, *rest = args
  rest
end

#task_nameObject



13
14
15
16
# File 'lib/duty/io/cli.rb', line 13

def task_name
  task, *rest = args
  task
end

#verbose?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/duty/io/cli.rb', line 31

def verbose?
  args.include?('-v') || args.include?('--verbose')
end