-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
usage.rb
53 lines (47 loc) · 1.13 KB
/
usage.rb
1
2
3
4
5
6
7
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
48
49
50
51
52
53
# frozen_string_literal: true
module TTY
module Option
class Usage
# @api public
def initialize(**properties)
@properties = properties
end
# Program name for display in help and error messages
#
# @api public
def program(name = (not_set = true), &block)
if not_set
@properties.fetch(:program) { ::File.basename($0, ".*") }
else
@properties[:program] = name
end
end
# Main way to show how all parameters can be used
#
# @api public
def banner(value = (not_set = true))
if not_set
@properties[:banner]
else
@properties[:banner] = value
end
end
def banner?
@properties.key?(:banner) && !@properties[:banner].nil?
end
# Description
#
# @api public
def desc(value = (not_set = true))
if not_set
@properties[:desc]
else
@properties[:desc] = value
end
end
def desc?
@properties.key?(:desc) && !@properties[:desc].nil?
end
end # Usage
end # Option
end # TTY