cli-mastermind 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 889cacb914ffc6a59675412d3d09deba8f531ec23633c4ea1fba1e56bef5fa28
4
- data.tar.gz: 8a1319225703fcadb958b83f61b021dbddbdead8285cc8c441e80773ddf6edb2
3
+ metadata.gz: e40196d83c1db754add3b8e4fbf4f10a26c4f66f1aff199261261bdfda66edc7
4
+ data.tar.gz: 0de3f8b0fe48d3c2496970380ea5f9ec3d5e73b15258bd3be5dcf7315516edc1
5
5
  SHA512:
6
- metadata.gz: 6618509b8ac96d95afd1e3b1306814786dcef86919de6332cd4cd0937a7eed88855c46c39d3167835aa1288a3bcbde854183113631dfdd65b216c9401285e6ea
7
- data.tar.gz: 95f2c85d604dab702b4dd14e7c08e66b2e963065f510a096cd28485213dbc3de257489ec7802d970bd8e752148d3ebe965f36b3359bd0ebb819bf736067ada58
6
+ metadata.gz: 034731a236c65aa88e3bd04dae4f41cf6324c128ea2847b5753ab86300f4c31a250ba3224afd8e14f33e746fabc319c7f046e3d3f380294ee7f1154d66fba2fc
7
+ data.tar.gz: a1b8f76371629f2fd7844cea59fc3e5e753f819a4f567562b0cfb7bcd7da3983149e2906b76efb19c4ebade3adf5188865b52568efb3052f0edb207269e7259f
data/README.md CHANGED
@@ -71,6 +71,9 @@ parallel, _Mastermind is designed to run only one task at a time_. Specifying
71
71
  multiple plan names on the command line is how you walk down the tree to a
72
72
  specific plan.
73
73
 
74
+ If you don't provide enough information to Mastermind to walk to an executable
75
+ plan, Mastermind will provide you with a list of available options to choose.
76
+
74
77
  For more information on how to use and configure Mastermind, check out the
75
78
  [wiki][wiki].
76
79
 
@@ -18,6 +18,18 @@ module CLI
18
18
  @config
19
19
  end
20
20
 
21
+ # Allows utilities wrapping Mastermind to specify that only plans under a
22
+ # particular path should be loaded.
23
+ def base_path=(base_path)
24
+ @base_path = base_path
25
+ end
26
+
27
+ # Allows utilities wrapping Mastermind to specify a top level plan without
28
+ # having to monkey with the incomming arguments.
29
+ def base_plan=(base_plan)
30
+ @base_plan = base_plan
31
+ end
32
+
21
33
  # Process incoming options and take an appropriate action.
22
34
  # This is normally called by the mastermind executable.
23
35
  def execute(cli_args=ARGV)
@@ -26,7 +38,7 @@ module CLI
26
38
  enable_ui if @arguments.display_ui?
27
39
 
28
40
  frame('Mastermind') do
29
- @config = spinner('Loading configuration') { Configuration.new }
41
+ @config = spinner('Loading configuration') { Configuration.new @base_path }
30
42
 
31
43
  if @arguments.dump_config?
32
44
  do_print_configuration
@@ -81,7 +93,7 @@ module CLI
81
93
  suffix = was_callable ? '{{*}}' : ' '
82
94
 
83
95
  puts stylize("{{yellow:#{name}}}")
84
- puts stylize("\t #{suffix} {{blue:#{value}}}")
96
+ puts stylize("\t #{suffix} {{blue:#{value.inspect}}}")
85
97
  print "\n"
86
98
  end
87
99
  end
@@ -138,9 +150,11 @@ module CLI
138
150
  def process_plan_names
139
151
  @arguments.do_command_expansion!(@config)
140
152
 
153
+ @arguments.insert_base_plan!(@base_plan) unless @base_plan.nil?
154
+
141
155
  @plan_stack = []
142
156
 
143
- @selected_plan = @plans
157
+ @selected_plan = @plans if @arguments.has_additional_plan_names?
144
158
 
145
159
  while @arguments.has_additional_plan_names?
146
160
  plan_name = @arguments.get_next_plan_name
@@ -168,7 +182,7 @@ module CLI
168
182
  end
169
183
 
170
184
  def user_is_sure?
171
- !@arguments.ask? or confirm("Execute plan #{@plan_stack.join('/')}?")
185
+ !@arguments.ask? or !@config.ask? or confirm("Execute plan #{@plan_stack.join('/')}?")
172
186
  end
173
187
 
174
188
  def execute_plan!
@@ -31,6 +31,13 @@ module CLI::Mastermind
31
31
  @plan_arguments = @alias_arguments + @plan_arguments
32
32
 
33
33
  @mastermind_arguments.flatten!
34
+ nil # prevent @mastermind_arguments from leaking
35
+ end
36
+
37
+ # Adds the given base plan to the beginning of the arguments array
38
+ def insert_base_plan!(base_plan)
39
+ @mastermind_arguments.unshift base_plan
40
+ nil # prevent @mastermind_arguments from leaking
34
41
  end
35
42
 
36
43
  def display_plans?
@@ -47,9 +47,11 @@ module CLI
47
47
  # masterplans, so it's important that it be set.
48
48
  add_attribute :project_root
49
49
 
50
- def initialize
50
+ def initialize(base_path=nil)
51
+ @base_path = base_path
51
52
  @loaded_masterplans = Set.new
52
53
  @plan_files = Set.new
54
+ @ask_for_confirmation = true
53
55
 
54
56
  # If no alias exists for a particular value, return that value
55
57
  @aliases = Hash.new { |_,k| k }
@@ -60,7 +62,13 @@ module CLI
60
62
 
61
63
  # Adds a set of filenames for plans into the set of +@plan_files+
62
64
  def add_plans(planfiles)
63
- @plan_files.merge(planfiles)
65
+ allowed_plans = if @base_path.nil?
66
+ planfiles
67
+ else
68
+ planfiles.select { |file| file.start_with? @base_path }
69
+ end
70
+
71
+ @plan_files.merge(allowed_plans)
64
72
  end
65
73
 
66
74
  # Loads all plan files added using +add_plans+
@@ -115,6 +123,14 @@ module CLI
115
123
  @aliases[input]
116
124
  end
117
125
 
126
+ def ask?
127
+ @ask_for_confirmation
128
+ end
129
+
130
+ def skip_confirmation!
131
+ @ask_for_confirmation = false
132
+ end
133
+
118
134
  private
119
135
 
120
136
  # Walks up the file tree looking for masterplans.
@@ -168,10 +184,18 @@ module CLI
168
184
  @config.public_send "#{attribute}=", value, &block
169
185
  end
170
186
 
187
+ # Define a user alias. User aliases are expanded as part of plan selection.
188
+ # @see ArgParse#do_command_expansion!
171
189
  def define_alias(name, arguments)
172
190
  @config.define_alias(name, arguments)
173
191
  end
174
192
 
193
+ # SKip confirmation before plan execution.
194
+ # Identical to -A.
195
+ def skip_confirmation
196
+ @config.skip_confirmation!
197
+ end
198
+
175
199
  private
176
200
 
177
201
  def supported_extensions
@@ -7,8 +7,8 @@ module CLI
7
7
 
8
8
  module VERSION
9
9
  RELEASE = 0
10
- MAJOR = 4
11
- MINOR = 1
10
+ MAJOR = 5
11
+ MINOR = 0
12
12
  PATCH = nil
13
13
 
14
14
  STRING = [RELEASE, MAJOR, MINOR, PATCH].compact.join('.').freeze
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cli-mastermind
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Hall
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-01 00:00:00.000000000 Z
11
+ date: 2019-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cli-ui