-
Notifications
You must be signed in to change notification settings - Fork 1
/
pione-action-list.rb
59 lines (49 loc) · 1.32 KB
/
pione-action-list.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
54
55
56
57
58
59
module Pione
module Command
# PioneActionList is a command definition of "pione action:list" for listing
# literate actions.
class PioneActionList < BasicCommand
#
# basic informations
#
command_name "pione action list"
command_banner "list action names in document"
#
# options
#
use_option :color
define_option(:compact) do |item|
item.long = "--compact"
item.desc = "one line list"
item.default = false
item.value = lambda {|b| b}
end
#
# command lifecycle: setup phase
#
setup :target
# Setup location of literate action document and action name.
def setup_target
abort("There are no literate action documents or packages.") if @argv[0].nil?
@location = Location[@argv[0]]
end
#
# command lifecycle: execution phase
#
execute :show_list
# Show list of action names.
def execute_show_list
names = LiterateAction::Document.load(@location).action_names.sort
if names.empty?
abort("no action names in %s" % @location.address)
else
if option[:compact]
puts names.join(" ")
else
names.each {|name| puts name}
end
end
end
end
end
end