Class: Cl::Help::Usage

Inherits:
Struct
  • Object
show all
Defined in:
lib/cl/help/usage.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cmdObject

Returns the value of attribute cmd

Returns:

  • (Object)

    the current value of cmd



3
4
5
# File 'lib/cl/help/usage.rb', line 3

def cmd
  @cmd
end

#ctxObject

Returns the value of attribute ctx

Returns:

  • (Object)

    the current value of ctx



3
4
5
# File 'lib/cl/help/usage.rb', line 3

def ctx
  @ctx
end

Instance Method Details

#executableObject



11
12
13
# File 'lib/cl/help/usage.rb', line 11

def executable
  ctx.name
end

#formatObject



4
5
6
7
8
9
# File 'lib/cl/help/usage.rb', line 4

def format
  usage = [executable, name]
  usage += cmd.args.map(&:to_s) # { |arg| "[#{arg}]" }
  usage << '[options]' if opts?
  usage.join(' ')
end

#nameObject



15
16
17
# File 'lib/cl/help/usage.rb', line 15

def name
  cmd.registry_key.to_s.gsub(':', ' ')
end

#opts?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/cl/help/usage.rb', line 19

def opts?
  cmd.opts.any?
end