MuranoCLI 2.2.4 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. checksums.yaml +4 -4
  2. data/.agignore +3 -0
  3. data/.gitignore +18 -1
  4. data/.rubocop.yml +222 -0
  5. data/.trustme.sh +185 -0
  6. data/.trustme.vim +24 -0
  7. data/Gemfile +23 -4
  8. data/LICENSE.txt +1 -1
  9. data/MuranoCLI.gemspec +43 -8
  10. data/README.markdown +9 -11
  11. data/Rakefile +187 -143
  12. data/TODO.taskpaper +2 -2
  13. data/bin/murano +51 -52
  14. data/docs/basic_example.rst +436 -0
  15. data/docs/completions/murano_completion-bash +3484 -0
  16. data/docs/demo.md +32 -32
  17. data/docs/develop.rst +391 -0
  18. data/lib/MrMurano.rb +21 -7
  19. data/lib/MrMurano/Account.rb +159 -174
  20. data/lib/MrMurano/Business.rb +381 -0
  21. data/lib/MrMurano/Config-Migrate.rb +32 -26
  22. data/lib/MrMurano/Config.rb +407 -128
  23. data/lib/MrMurano/Content.rb +191 -0
  24. data/lib/MrMurano/Gateway.rb +489 -0
  25. data/lib/MrMurano/Keystore.rb +48 -0
  26. data/lib/MrMurano/Passwords.rb +103 -0
  27. data/lib/MrMurano/ProjectFile.rb +121 -79
  28. data/lib/MrMurano/ReCommander.rb +114 -10
  29. data/lib/MrMurano/Setting.rb +90 -0
  30. data/lib/MrMurano/Solution-ServiceConfig.rb +89 -45
  31. data/lib/MrMurano/Solution-Services.rb +461 -166
  32. data/lib/MrMurano/Solution-Users.rb +70 -31
  33. data/lib/MrMurano/Solution.rb +372 -13
  34. data/lib/MrMurano/SolutionId.rb +73 -0
  35. data/lib/MrMurano/SyncRoot.rb +137 -0
  36. data/lib/MrMurano/SyncUpDown.rb +594 -284
  37. data/lib/MrMurano/Webservice-Cors.rb +71 -0
  38. data/lib/MrMurano/Webservice-Endpoint.rb +234 -0
  39. data/lib/MrMurano/Webservice-File.rb +193 -0
  40. data/lib/MrMurano/Webservice.rb +51 -0
  41. data/lib/MrMurano/commands.rb +18 -15
  42. data/lib/MrMurano/commands/business.rb +300 -6
  43. data/lib/MrMurano/commands/completion-bash.erb +166 -0
  44. data/lib/MrMurano/commands/{zshcomplete.erb → completion-zsh.erb} +0 -0
  45. data/lib/MrMurano/commands/completion.rb +76 -39
  46. data/lib/MrMurano/commands/config.rb +108 -44
  47. data/lib/MrMurano/commands/content.rb +115 -72
  48. data/lib/MrMurano/commands/cors.rb +29 -14
  49. data/lib/MrMurano/commands/devices.rb +286 -0
  50. data/lib/MrMurano/commands/domain.rb +52 -12
  51. data/lib/MrMurano/commands/gb.rb +24 -9
  52. data/lib/MrMurano/commands/globals.rb +64 -0
  53. data/lib/MrMurano/commands/init.rb +377 -155
  54. data/lib/MrMurano/commands/keystore.rb +92 -82
  55. data/lib/MrMurano/commands/link.rb +300 -0
  56. data/lib/MrMurano/commands/login.rb +74 -11
  57. data/lib/MrMurano/commands/logs.rb +63 -32
  58. data/lib/MrMurano/commands/mock.rb +57 -29
  59. data/lib/MrMurano/commands/password.rb +57 -39
  60. data/lib/MrMurano/commands/postgresql.rb +127 -94
  61. data/lib/MrMurano/commands/settings.rb +203 -0
  62. data/lib/MrMurano/commands/show.rb +79 -38
  63. data/lib/MrMurano/commands/solution.rb +423 -5
  64. data/lib/MrMurano/commands/solution_picker.rb +547 -0
  65. data/lib/MrMurano/commands/status.rb +195 -61
  66. data/lib/MrMurano/commands/sync.rb +78 -39
  67. data/lib/MrMurano/commands/timeseries.rb +71 -55
  68. data/lib/MrMurano/commands/tsdb.rb +113 -87
  69. data/lib/MrMurano/commands/usage.rb +57 -15
  70. data/lib/MrMurano/hash.rb +100 -10
  71. data/lib/MrMurano/http.rb +187 -43
  72. data/lib/MrMurano/makePretty.rb +16 -14
  73. data/lib/MrMurano/optparse.rb +2178 -0
  74. data/lib/MrMurano/progress.rb +138 -0
  75. data/lib/MrMurano/schema/resource-v1.0.0.yaml +32 -0
  76. data/lib/MrMurano/template/projectFile.murano.erb +16 -13
  77. data/lib/MrMurano/verbosing.rb +166 -29
  78. data/lib/MrMurano/version.rb +30 -1
  79. data/spec/Account-Passwords_spec.rb +21 -4
  80. data/spec/Account_spec.rb +69 -146
  81. data/spec/Business_spec.rb +290 -0
  82. data/spec/ConfigFile_spec.rb +1 -0
  83. data/spec/ConfigMigrate_spec.rb +12 -8
  84. data/spec/Config_spec.rb +40 -34
  85. data/spec/Content_spec.rb +363 -0
  86. data/spec/GatewayBase_spec.rb +54 -0
  87. data/spec/GatewayDevice_spec.rb +321 -0
  88. data/spec/GatewayResource_spec.rb +266 -0
  89. data/spec/GatewaySettings_spec.rb +120 -0
  90. data/spec/Http_spec.rb +18 -8
  91. data/spec/Mock_spec.rb +2 -2
  92. data/spec/ProjectFile_spec.rb +25 -14
  93. data/spec/Setting_spec.rb +110 -0
  94. data/spec/Solution-ServiceConfig_spec.rb +44 -5
  95. data/spec/Solution-ServiceEventHandler_spec.rb +23 -14
  96. data/spec/Solution-ServiceModules_spec.rb +47 -37
  97. data/spec/Solution-UsersRoles_spec.rb +10 -8
  98. data/spec/Solution_spec.rb +17 -8
  99. data/spec/SyncRoot_spec.rb +46 -20
  100. data/spec/SyncUpDown_spec.rb +437 -201
  101. data/spec/Verbosing_spec.rb +12 -4
  102. data/spec/{Solution-Cors_spec.rb → Webservice-Cors_spec.rb} +23 -20
  103. data/spec/{Solution-Endpoint_spec.rb → Webservice-Endpoint_spec.rb} +43 -41
  104. data/spec/{Solution-File_spec.rb → Webservice-File_spec.rb} +44 -33
  105. data/spec/Webservice-Setting_spec.rb +89 -0
  106. data/spec/_workspace.rb +4 -4
  107. data/spec/cmd_business_spec.rb +9 -4
  108. data/spec/cmd_common.rb +44 -1
  109. data/spec/cmd_content_spec.rb +43 -17
  110. data/spec/cmd_cors_spec.rb +4 -4
  111. data/spec/cmd_device_spec.rb +61 -16
  112. data/spec/cmd_domain_spec.rb +29 -6
  113. data/spec/cmd_init_spec.rb +281 -126
  114. data/spec/cmd_keystore_spec.rb +3 -3
  115. data/spec/cmd_link_spec.rb +98 -0
  116. data/spec/cmd_password_spec.rb +1 -1
  117. data/spec/cmd_setting_application_spec.rb +260 -0
  118. data/spec/cmd_setting_product_spec.rb +220 -0
  119. data/spec/cmd_status_spec.rb +223 -114
  120. data/spec/cmd_syncdown_spec.rb +115 -35
  121. data/spec/cmd_syncup_spec.rb +68 -15
  122. data/spec/cmd_usage_spec.rb +35 -8
  123. data/spec/fixtures/dumped_config +6 -4
  124. data/spec/fixtures/gateway_resource_files/resources.notyaml +12 -0
  125. data/spec/fixtures/gateway_resource_files/resources.yaml +13 -0
  126. data/spec/fixtures/gateway_resource_files/resources_invalid.yaml +13 -0
  127. data/spec/fixtures/mrmuranorc_deleted_bob +0 -2
  128. data/spec/fixtures/product_spec_files/lightbulb.yaml +20 -13
  129. data/spec/fixtures/{syncable_content → syncable_conflict}/services/devdata.lua +1 -1
  130. data/spec/fixtures/{syncable_content → syncable_conflict}/services/timers.lua +0 -0
  131. data/spec/spec_helper.rb +5 -0
  132. metadata +262 -171
  133. data/bin/mr +0 -8
  134. data/lib/MrMurano/Product-1P-Device.rb +0 -145
  135. data/lib/MrMurano/Product-Resources.rb +0 -205
  136. data/lib/MrMurano/Product.rb +0 -358
  137. data/lib/MrMurano/Solution-Cors.rb +0 -47
  138. data/lib/MrMurano/Solution-Endpoint.rb +0 -191
  139. data/lib/MrMurano/Solution-File.rb +0 -166
  140. data/lib/MrMurano/commands/assign.rb +0 -57
  141. data/lib/MrMurano/commands/businessList.rb +0 -45
  142. data/lib/MrMurano/commands/product.rb +0 -14
  143. data/lib/MrMurano/commands/productCreate.rb +0 -39
  144. data/lib/MrMurano/commands/productDelete.rb +0 -33
  145. data/lib/MrMurano/commands/productDevice.rb +0 -87
  146. data/lib/MrMurano/commands/productDeviceIdCmds.rb +0 -89
  147. data/lib/MrMurano/commands/productList.rb +0 -45
  148. data/lib/MrMurano/commands/productWrite.rb +0 -27
  149. data/lib/MrMurano/commands/solutionCreate.rb +0 -41
  150. data/lib/MrMurano/commands/solutionDelete.rb +0 -34
  151. data/lib/MrMurano/commands/solutionList.rb +0 -45
  152. data/spec/ProductBase_spec.rb +0 -113
  153. data/spec/ProductContent_spec.rb +0 -162
  154. data/spec/ProductResources_spec.rb +0 -329
  155. data/spec/Product_1P_Device_spec.rb +0 -202
  156. data/spec/Product_1P_RPC_spec.rb +0 -175
  157. data/spec/Product_spec.rb +0 -153
  158. data/spec/Solution-ServiceDevice_spec.rb +0 -176
  159. data/spec/cmd_assign_spec.rb +0 -51
@@ -0,0 +1,138 @@
1
+ # Last Modified: 2017.08.02 /coding: utf-8
2
+ # frozen_string_literal: true
3
+
4
+ # Copyright © 2016-2017 Exosite LLC.
5
+ # License: MIT. See LICENSE.txt.
6
+ # vim:tw=0:ts=2:sw=2:et:ai
7
+
8
+ require 'highline'
9
+ require 'inflecto'
10
+ require 'singleton'
11
+ require 'whirly'
12
+
13
+ module MrMurano
14
+ # Progress is a singleton (evil!) that implements a terminal progress bar.
15
+ class Progress
16
+ include Singleton
17
+
18
+ def initialize
19
+ @whirly_msg = ''
20
+ @whirly_time = nil
21
+ @whirly_users = 0
22
+ @whirly_cols = 0
23
+ @whirly_pauses = 0
24
+ end
25
+
26
+ EXO_QUADRANTS = [
27
+ '▚',
28
+ '▘',
29
+ '▝',
30
+ '▞',
31
+ '▖',
32
+ '▗',
33
+ ].freeze
34
+
35
+ def whirly_start(msg)
36
+ if $cfg['tool.verbose']
37
+ whirly_pause if @whirly_users > 0
38
+ say msg
39
+ whirly_unpause if @whirly_users > 0
40
+ end
41
+ return if $cfg['tool.no-progress']
42
+ # Count the number of calls to whirly_start, so that the
43
+ # first call to whirly_start is the message that gets
44
+ # printed. This way, methods can define a default message
45
+ # to use, but then callers of those methods can choose to
46
+ # display a different message.
47
+ @whirly_users += 1
48
+ # The first Whirly message is the one we show.
49
+ return if @whirly_users > 1
50
+ @whirly_msg = msg
51
+ whirly_stop
52
+ whirly_show
53
+ end
54
+
55
+ def whirly_show
56
+ Whirly.start(
57
+ spinner: EXO_QUADRANTS,
58
+ status: @whirly_msg,
59
+ append_newline: false,
60
+ #remove_after_stop: false,
61
+ #stream: $stderr,
62
+ )
63
+ @whirly_time = Time.now
64
+ # The whitespace we add ends up getting picked up if you copy
65
+ # from the terminal. [lb] not sure if we can fix that... but
66
+ # we can at least minimize the amount of it to the longest
67
+ # message, rather than the terminal column width.
68
+ #@whirly_cols, _rows = HighLine::SystemExtensions.terminal_size
69
+ # Note that Whirly adds '...', so add its length, too.
70
+ # rubocop:disable Performance/FixedSize
71
+ # Do not compute the size of statically sized objects.
72
+ @whirly_cols = @whirly_msg.length + '...'.length
73
+ end
74
+
75
+ def whirly_stop(force: false)
76
+ return if $cfg['tool.no-progress'] || @whirly_time.nil?
77
+ if force
78
+ @whirly_users = 0
79
+ else
80
+ @whirly_users -= 1
81
+ end
82
+ return unless @whirly_users.zero?
83
+ whirly_linger
84
+ whirly_clear
85
+ end
86
+
87
+ def whirly_clear
88
+ Whirly.stop
89
+ # The progress indicator is always overwritten.
90
+ return unless @whirly_cols
91
+ $stdout.print((' ' * @whirly_cols) + "\r")
92
+ $stdout.flush
93
+ end
94
+
95
+ def whirly_linger
96
+ return if $cfg['tool.no-progress'] || @whirly_time.nil?
97
+ not_so_fast = 0.55 - (Time.now - @whirly_time)
98
+ @whirly_time = nil
99
+ sleep(not_so_fast) if not_so_fast > 0
100
+ end
101
+
102
+ def whirly_msg(msg)
103
+ return if $cfg['tool.no-progress']
104
+ if @whirly_time.nil?
105
+ whirly_start msg
106
+ else
107
+ @whirly_msg = msg
108
+ #self.whirly_linger
109
+ # Clear the line.
110
+ Whirly.configure(status: ' ' * @whirly_cols)
111
+ Whirly.configure(status: @whirly_msg)
112
+ @whirly_cols = @whirly_msg.length + '...'.length
113
+ end
114
+ end
115
+
116
+ def whirly_pause
117
+ @whirly_pauses += 1
118
+ return if @whirly_pauses > 1
119
+ return if @whirly_users.zero?
120
+ whirly_clear
121
+ end
122
+
123
+ def whirly_unpause
124
+ @whirly_pauses -= 1
125
+ raise 'Whirly unpaused once too many' if @whirly_pauses < 0
126
+ return unless @whirly_pauses == 0
127
+ return if @whirly_users.zero?
128
+ whirly_show
129
+ end
130
+
131
+ def whirly_interject
132
+ whirly_pause
133
+ yield
134
+ whirly_unpause
135
+ end
136
+ end
137
+ end
138
+
@@ -0,0 +1,32 @@
1
+ ---
2
+ type: object
3
+ description: Map of the Resources allowed on Devices in this project.
4
+ patternProperties:
5
+ "[a-z]+":
6
+ type: object
7
+ description: Name of a resource with info
8
+ properties:
9
+ format:
10
+ type: string
11
+ pattern: "(string|boolean|number)"
12
+ description: The type of data stored in aliases for this resource.
13
+ unit:
14
+ type: string
15
+ description: Helpful unit description for the alias.
16
+ settable:
17
+ type: boolean
18
+ description: True if the cloud can write to this
19
+ allowed:
20
+ type: array
21
+ description: |-
22
+ Simple data format validations.
23
+
24
+ Any set of values that matches the format. Although for number format,
25
+ you can also use a string that represents a range. eg. [1,3,"9-11",21]
26
+
27
+ Or for string string format eg. ["on", "off"].
28
+
29
+ Boolean is implied [true, false] and not needed.
30
+
31
+ # vim: set et sw=2 ts=2 :
32
+
@@ -30,28 +30,31 @@ info:
30
30
  #
31
31
  #
32
32
  #routes:
33
- # #Start off with the directory name we want to keep everything in.
33
+ # # Start off with the directory name we want to keep everything in.
34
34
  # location: routes
35
35
  #
36
- # #Then use globs to find all of the files that can contain route code.
37
- # #If using single glob, then can be just the string.
36
+ # # Then use globs to find all of the files that can contain route code.
37
+ # # If using single glob, then can be just the string.
38
38
  # include: ['{,../endpoints}/*.lua', '{,../endpoints}/*/*.lua']
39
+ # # HINT: A single asterisk glob, like */*.lua, only searches top-level
40
+ # # directories. A double asterkisk, like **/*.lua, recursively searches
41
+ # # all sub-directories.
39
42
  # #include: '**/*.lua'
40
43
  #
41
- # #Then remove all that match these globs. Again, if a single, can drop the array.
42
- # #If not excluding, use empty array [], or empty node.
44
+ # # Then remove all that match these globs. Again, if a single, can drop the array.
45
+ # # If not excluding, use empty array [], or empty node.
43
46
  # exclude: ['*_test.lua', '*_spec.lua', '**/.*']
44
47
  #
45
- # #That leaves a list of files with API routes in them. Each Route file can
46
- # #contain one or more actual routes that are synced with Murano.
48
+ # # That leaves a list of files with API routes in them. Each Route file can
49
+ # # contain one or more actual routes that are synced with Murano.
47
50
  #
48
51
  #
49
- # #If you are hosting your website somewhere other than on Murano, and you want to
50
- # #tighten up what Cross Origin calls are allowed, you can set that here.
52
+ # # If you are hosting your website somewhere other than on Murano, and you want to
53
+ # # tighten up what Cross Origin calls are allowed, you can set that here.
51
54
  #
52
- # #Either point to a YAML file
55
+ # # Either point to a YAML file
53
56
  # cors: "cors.yaml"
54
- # #Or include it directly
57
+ # # Or include it directly
55
58
  # cors: {"origin":true,"methods":["HEAD","GET","POST","PUT","DELETE","OPTIONS","PATCH"],"headers":["Content-Type","Cookie","Authorization"],"credentials":true}
56
59
  #
57
60
  #assets:
@@ -62,8 +65,8 @@ info:
62
65
  #
63
66
  #modules:
64
67
  # location: modules
65
- # include: ['*.lua', '*/*.lua']
66
- # exclude: ['*_test.lua', '*_spec.lua', '**/.*']
68
+ # include: ['*.lua', '**/*.lua']
69
+ # exclude: ['*_test.lua', '*_spec.lua']
67
70
  #
68
71
  #services:
69
72
  # location: services
@@ -1,62 +1,96 @@
1
+ # Last Modified: 2017.08.17 /coding: utf-8
2
+ # frozen_string_literal: true
3
+
4
+ # Copyright © 2016-2017 Exosite LLC.
5
+ # License: MIT. See LICENSE.txt.
6
+ # vim:tw=0:ts=2:sw=2:et:ai
7
+
8
+ require 'csv'
1
9
  require 'highline'
2
- require 'yaml'
10
+ require 'inflecto'
3
11
  require 'json'
12
+ require 'paint'
4
13
  require 'pp'
5
- require 'csv'
6
14
  require 'terminal-table'
15
+ require 'whirly'
16
+ require 'yaml'
17
+ require 'MrMurano/progress'
7
18
 
8
19
  module MrMurano
20
+ # Verbose is a mixin for various terminal output features.
9
21
  module Verbose
10
22
  def verbose(msg)
11
- if $cfg['tool.verbose'] then
12
- say msg
13
- end
23
+ MrMurano::Verbose.verbose(msg)
24
+ end
25
+
26
+ def self.verbose(msg)
27
+ whirly_interject { say msg } if $cfg['tool.verbose']
14
28
  end
15
29
 
16
30
  def debug(msg)
17
- if $cfg['tool.debug'] then
18
- say msg
19
- end
31
+ MrMurano::Verbose.debug(msg)
32
+ end
33
+
34
+ def self.debug(msg)
35
+ whirly_interject { say msg } if $cfg['tool.debug']
20
36
  end
21
37
 
22
38
  def warning(msg)
23
- $stderr.puts HighLine.color(msg, :yellow)
39
+ MrMurano::Verbose.warning(msg)
40
+ end
41
+
42
+ def self.warning(msg)
43
+ whirly_interject { $stderr.puts(HighLine.color(msg, :yellow)) }
24
44
  end
25
45
 
26
46
  def error(msg)
27
- $stderr.puts HighLine.color(msg, :red)
47
+ MrMurano::Verbose.error(msg)
48
+ end
49
+
50
+ def self.error(msg)
51
+ # See also Commander::say_error
52
+ whirly_interject { $stderr.puts(HighLine.color(msg, :red)) }
28
53
  end
29
54
 
30
55
  ## Output tabular data
31
56
  # +data+:: Data to write. Preferably a Hash with :headers and :rows
32
57
  # +ios+:: Output stream to write to, if nil, then use $stdout
33
58
  # Output is either a nice visual table or CSV.
59
+
60
+ TABULARIZE_DATA_FORMAT_ERROR = 'Unexpected data format: do not know how to tabularize.'
61
+
34
62
  def tabularize(data, ios=nil)
63
+ MrMurano::Verbose.tabularize(data, ios)
64
+ end
65
+
66
+ def self.tabularize(data, ios=nil)
35
67
  fmt = $cfg['tool.outformat']
36
68
  ios = $stdout if ios.nil?
37
69
  cols = nil
38
70
  rows = nil
39
71
  title = nil
40
- if data.kind_of?(Hash) then
41
- cols = data[:headers] if data.has_key?(:headers)
42
- rows = data[:rows] if data.has_key?(:rows)
72
+ if data.is_a?(Hash)
73
+ cols = data[:headers] if data.key?(:headers)
74
+ rows = data[:rows] if data.key?(:rows)
43
75
  title = data[:title]
44
- elsif data.kind_of?(Array) then
76
+ elsif data.is_a?(Array)
45
77
  rows = data
46
- elsif data.respond_to?(:to_a) then
78
+ elsif data.respond_to?(:to_a)
47
79
  rows = data.to_a
48
- elsif data.respond_to?(:each) then
80
+ elsif data.respond_to?(:each)
49
81
  rows = []
50
- data.each{|i| rows << i}
82
+ # MAYBE/2017-07-02: Does shover operator work on frozen string literals?
83
+ data.each { |i| rows << i }
51
84
  else
52
- error "Don't know how to tabularize data."
85
+ error TABULARIZE_DATA_FORMAT_ERROR
53
86
  return
54
87
  end
55
- if fmt =~ /csv/i then
88
+ if fmt =~ /csv/i
56
89
  cols = [] if cols.nil?
57
90
  rows = [[]] if rows.nil?
58
- CSV(ios, :headers=>cols, :write_headers=>(not cols.empty?)) do |csv|
59
- rows.each{|v| csv << v}
91
+ CSV(ios, headers: cols, write_headers: !cols.empty?) do |csv|
92
+ # MAYBE/2017-07-02: Does shover operator work on frozen string literals?
93
+ rows.each { |v| csv << v }
60
94
  end
61
95
  else
62
96
  # table.
@@ -70,7 +104,7 @@ module MrMurano
70
104
 
71
105
  ## Format and print the object
72
106
  # Handles many of the raw 'unpolished' formats.
73
- def outf(obj, ios=nil, &block)
107
+ def outf(obj, ios=nil, &_block)
74
108
  fmt = $cfg['tool.outformat']
75
109
  ios = $stdout if ios.nil?
76
110
  case fmt
@@ -82,18 +116,121 @@ module MrMurano
82
116
  ios.puts obj.to_json
83
117
  else # aka best.
84
118
  # sometime ‘best’ is only know by the caller, so block.
85
- if block_given? then
119
+ if block_given?
86
120
  yield obj, ios
121
+ elsif obj.is_a?(Array)
122
+ obj.each { |i| ios.puts i.to_s }
123
+ else
124
+ ios.puts obj.to_s
125
+ end
126
+ end
127
+ end
128
+
129
+ def self.ask_yes_no(question, default)
130
+ answer = default
131
+ whirly_interject do
132
+ confirm = ask(question)
133
+ if default
134
+ answer = !%w[n no].include?(confirm.downcase)
87
135
  else
88
- if obj.kind_of?(Array) then
89
- obj.each {|i| ios.puts i.to_s}
90
- else
91
- ios.puts obj.to_s
92
- end
136
+ answer = %w[y ye yes].include?(confirm.downcase)
93
137
  end
94
138
  end
139
+ answer
140
+ end
141
+
142
+ def ask_yes_no(question, default)
143
+ MrMurano::Verbose.ask_yes_no(question, default)
144
+ end
145
+
146
+ def self.cmd_confirm_delete!(name, auto_yes, exit_msg)
147
+ if auto_yes
148
+ yield true if block_given?
149
+ return true
150
+ end
151
+ confirmed = MrMurano::Verbose.ask_yes_no(
152
+ "Really delete ‘#{name}’? [y/N] ", false
153
+ )
154
+ MrMurano::Verbose.warning(exit_msg) if !confirmed && exit_msg
155
+ if block_given?
156
+ yield confirmed
157
+ elsif !confirmed
158
+ exit 1
159
+ end
160
+ confirmed
161
+ end
162
+
163
+ def cmd_confirm_delete!(name, auto_yes, exit_msg)
164
+ MrMurano::Verbose.cmd_confirm_delete!(name, auto_yes, exit_msg)
95
165
  end
96
166
 
167
+ def self.pluralize?(word, count)
168
+ count == 1 && word || Inflecto.pluralize(word)
169
+ end
170
+
171
+ def pluralize?(word, count)
172
+ MrMurano::Verbose.pluralize?(word, count)
173
+ end
174
+
175
+ # 2017-07-01: Whirly wrappers. Maybe delete someday
176
+ # (after replacing all MrMurano::Verbose.whirly_*
177
+ # with MrMurano::Progress.whirly_*).
178
+
179
+ def whirly_start(msg)
180
+ MrMurano::Progress.instance.whirly_start(msg)
181
+ end
182
+
183
+ def whirly_stop(force: false)
184
+ MrMurano::Progress.instance.whirly_stop(force: force)
185
+ end
186
+
187
+ def whirly_linger
188
+ MrMurano::Progress.instance.whirly_linger
189
+ end
190
+
191
+ def whirly_msg(msg)
192
+ MrMurano::Progress.instance.whirly_msg(msg)
193
+ end
194
+
195
+ def whirly_pause
196
+ MrMurano::Progress.instance.whirly_pause
197
+ end
198
+
199
+ def whirly_unpause
200
+ MrMurano::Progress.instance.whirly_unpause
201
+ end
202
+
203
+ def whirly_interject(&block)
204
+ MrMurano::Progress.instance.whirly_interject(&block)
205
+ end
206
+
207
+ def self.whirly_start(msg)
208
+ MrMurano::Progress.instance.whirly_start(msg)
209
+ end
210
+
211
+ def self.whirly_stop(force: false)
212
+ MrMurano::Progress.instance.whirly_stop(force: force)
213
+ end
214
+
215
+ def self.whirly_linger
216
+ MrMurano::Progress.instance.whirly_linger
217
+ end
218
+
219
+ def self.whirly_msg(msg)
220
+ MrMurano::Progress.instance.whirly_msg(msg)
221
+ end
222
+
223
+ def self.whirly_pause
224
+ MrMurano::Progress.instance.whirly_pause
225
+ end
226
+
227
+ def self.whirly_unpause
228
+ MrMurano::Progress.instance.whirly_unpause
229
+ end
230
+
231
+ def self.whirly_interject(&block)
232
+ MrMurano::Progress.instance.whirly_interject(&block)
233
+ end
97
234
  end
98
235
  end
99
- # vim: set ai et sw=2 ts=2 :
236
+