cli-mastermind 0.1.0 → 0.1.1

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: 4f9d964ad9871b8f4b0b44fce7340487954d1fa00396fafa1c546be54673ced8
4
- data.tar.gz: b1ca65e254ac504bdfdc3badde8964dd7f21321b3ef882f6546b7e8c97e94e12
3
+ metadata.gz: 3a932d12a8cc90bcdf962b0980e81a6ccb0e11b3c2be7545c62dd8c9de93be1d
4
+ data.tar.gz: 80ba0ee26a3ec8aa2f85cea56b1c62f982066a06608d12010b234cbdad90e514
5
5
  SHA512:
6
- metadata.gz: ba400135252064d5ae3709c8759ffaac92b19f6c3f3cb55a4db8da99401a0c52becd4507ed075a9ca185bc28b96018eac7763397d8bfd9dd7cc96d4f5cd850d5
7
- data.tar.gz: be4dbac7ae0e6d37fa76a55893e9a64c554081fff45bb6f4692e9f5fa22a581f0989ee4e5a0a3661c69f505d020aad0fe62d050187398be4d4fc08b263e03b0d
6
+ metadata.gz: f27becd1dcccb97e1ef7e4764e05711b09e1ef031a7e97c35100999992220dae941648751a522a8f8d0d556054d605622bf6f0238834dbecb4d63271f3034216
7
+ data.tar.gz: 4c60255fa408f8e73c602ab5e855623073b2430a65fcc4e578a4a4ee01a03b172d82dc1ba596798dff488ab9faff08896896ad6ee5e35b4176fb9ba0b4f1e2a6
data/README.md CHANGED
@@ -1,32 +1,32 @@
1
1
  # Mastermind
2
2
 
3
- Mastermind is a CLI toolkit. It's purpose is to help build, configure, and run
3
+ Mastermind is a CLI framework. It's purpose is to help build, configure, and run
4
4
  command line tools.
5
5
 
6
- Mastermind is designed for flexibility, extensibility, and minimal dependencies.
6
+ Mastermind is designed for flexibility, extensibility, minimal dependencies.
7
7
 
8
8
  ## Flexibility
9
9
 
10
10
  Mastermind is written in Ruby and, therefore, provides first-class citizenship
11
- to that language and uses Ruby's syntax and semantics in its primary configuration
12
- files.
11
+ to that language and uses Ruby's syntax and semantics in its configuration files.
13
12
 
14
- Mastermind looks for and executes `.masterplan` files recursively up the file tree
15
- until it reaches the root of your project, if defined, or your home directory,
13
+ Mastermind looks for and evaluates `.masterplan` files recursively up the file
14
+ tree until it reaches the root of your project, if defined, or your home directory,
16
15
  if it's not. Additionally, it always looks for and attempts to load a `.masterplan`
17
16
  file in your home directory, if one exists.
18
17
 
19
18
  In this way, configuration for your tools can live where it makes the most sense
20
19
  for it to live with as much or as little duplication as you deem necessary.
21
20
 
22
- See [Writing Masterplans](#writing-masterplans) for more on their structure and semantics.
21
+ See [Writing Masterplans][writing-masterplans] for more on their structure and
22
+ semantics.
23
23
 
24
- Mastermind makes up for the lack of language flexibility in its configuration
25
- with full flexibility in its planfiles. Which brings us to...
24
+ Mastermind makes up for the lack of flexibility in its configuration with full
25
+ flexibility in its planfiles. Which brings us to...
26
26
 
27
27
  ## Extensibility
28
28
 
29
- Mastermind is designed from the outset to provide means of extending its planfile
29
+ Mastermind is designed from the outset to provide a means of extending its planfile
30
30
  formats through custom `Loader`s. In fact, Mastermind's own `PlanfileLoader` is
31
31
  the first of such loaders. You can specify your own file extensions and provide
32
32
  your own loaders as needed.
@@ -35,11 +35,15 @@ As long as the objects returned by your loader quack like a `Plan`, Mastermind
35
35
  won't fuss at them. After all, you can't take over the world if your busy mucking
36
36
  about in the details!
37
37
 
38
+ Obviously, it'd be a bit difficult to write your plan files in an entirely separate
39
+ language, but there's nothing stopping you from delegating actions to another
40
+ executable or even writing some C code to call into something else alltogether.
41
+
38
42
  ## Minimal Dependencies
39
43
 
40
44
  Mastermind only has one dependency, Shopify's excelent [cli-ui project][cli-ui].
41
- It doesn't require that you load it in your Gemfile or do anything in particular.
42
- All you need to be able to do is run its executable and Mastermind does the rest.
45
+ Mastermind doesn't require that you load it in your Gemfile or add anything to
46
+ your project's configuration files.
43
47
 
44
48
  ## Usage
45
49
 
@@ -57,90 +61,8 @@ You can then process those arguments however you like or ignore them completely!
57
61
 
58
62
  Unlike Rake and other, similar, tools that allow you to run multiple tasks in
59
63
  parallel, Mastermind is designed to run only one task at a time. Specifying
60
- multiple plans on the command line is how you walk down the tree to a specific
61
- plan.
62
-
63
- ### Writing Masterplans
64
-
65
- `.masterplan` files use a minimal DSL to configure Mastermind and load planfiles.
66
- Some of these commands have sensible defaults designed to keep configuration to
67
- a minimum.
68
-
69
- #### Masterplan DSL
70
-
71
- ##### `project_root [directory]`
72
-
73
- Specifies the root of your project. Must be specified to prevent Mastermind
74
- from scanning more of your filesystem than it needs to. The easiest way to
75
- do this is to just specify it in a `.masterplan` file in the actual root of
76
- your project.
77
-
78
- Aliased as `at_project_root`. The argument defaults to the directory of the
79
- current `.masterplan`.
80
-
81
- ##### `plan_files [directory]`
82
-
83
- Specifies that plan files exist in the given directory. Mastermind will search
84
- this directory for any files that end in a supported extension and mark them
85
- for loading. By default, Mastermind only supports files with a `.plan` extension.
86
-
87
- Aliased as `has_plan_files`. The argument defaults to a `plans` directory in
88
- the same directory as the current `.masterplan`.
89
-
90
- ##### `plan_file filename[, filename[, ...]]`
91
-
92
- Instructs Mastermind to load the planfiles located at the given filenames.
93
-
94
- ##### `configure attribute [value] [&block]`
95
-
96
- Used to set arbitrary configuration options. When a configuration option is
97
- set in multiple `.masterplan` files, the "closest" one to your invocation wins.
98
- In other words, since Mastermind reads `.masterplan` files starting in your
99
- current directory and working it's way "up" the hierarchy, the first `.masterplan`
100
- that specifies a configuration option "wins".
101
-
102
- When provided a block, the value is computed the first time the option is called
103
- for. The block runs in the context of the `Configuration` object built up by
104
- all the loaded `.masterplan` files, so it has access to all previously set
105
- configuration options.
106
-
107
- The block is only executed once. After that, the value is cached so that it
108
- doesn't need to be recomputed.
109
-
110
- If both a block and a value are given, the block is ignored and only the value
111
- is stored.
112
-
113
- ##### `see_also filename`
114
-
115
- Instructs Mastermind to also load the configuration specified in `filename`.
116
- This file does _not_ have to be named `.masterplan` but _does_ have to conform
117
- to the syntax outlined here.
118
-
119
- ### Writing Planfiles
120
-
121
- By default, planfiles use a very simple DSL that will feel familiar to anyone
122
- that's ever used Rake. The biggest difference between Rake (and similar tools)
123
- and Mastermind is that Mastermind has no support for dependent tasks or parallel
124
- tasks. If your workflow requires either of those things, Mastermind is probably
125
- not the tool you want to use. Or, rather, not the _only_ tool you want to use.
126
-
127
- #### Planfile DSL
128
-
129
- ##### `plot name &block`
130
-
131
- Creates a Plan that contains children with the given `name`. This is similar
132
- to the `namespace` command in a Rakefile. The Plans created inside the block
133
- are added as children of this Plan.
134
-
135
- ##### `description text`
136
-
137
- Provides a description for the next Plan created. Plans created with `plot`
138
- can also have descriptions.
139
-
140
- ##### `plan name &block`
141
-
142
- Creates a Plan with the given name and sets the given block as its action.
143
- This block is passed the arguments from the command line and is run as a Plan.
64
+ multiple plan names on the command line is how you walk down the tree to a
65
+ specific plan.
144
66
 
145
67
  ## Development
146
68
 
@@ -161,4 +83,5 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/chall8
161
83
 
162
84
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
163
85
 
86
+ [writing-masterplans]: wiki/Writing-Masterplans
164
87
  [cli-ui]: https://github.com/shopify/cli-ui
@@ -144,12 +144,6 @@ module CLI
144
144
  exit 1
145
145
  end
146
146
  end
147
-
148
- # Prevent the prompt from exploading
149
- if @selected_plan.nil? and @plans.count == 1
150
- @selected_plan = @plans.values.first
151
- @plan_stack << titleize(@selected_plan.name)
152
- end
153
147
  end
154
148
 
155
149
  def do_interactive_plan_selection
@@ -66,10 +66,14 @@ module CLI::Mastermind::Interface
66
66
  end
67
67
 
68
68
  # Display an interactive list of options for the user to select.
69
+ # If less than 2 options would be displayed, the default value is automatically
70
+ # returned.
69
71
  #
70
72
  # @param +question+ The question to ask the user
71
73
  # @param +options:+ Array|Hash the options to display
72
- # @param +default:+ The value or key to display first. Defaults to the first option.
74
+ # @param +default:+ The default value for this question. Defaults to the first
75
+ # option. The default option is displayed first. Assumed to
76
+ # exist within the given options.
73
77
  #
74
78
  # Any other keyword arguments given are passed down into +CLI::UI::Prompt.ask+.
75
79
  #
@@ -95,6 +99,8 @@ module CLI::Mastermind::Interface
95
99
  options.dup.tap { |o| o.delete(default_text) }
96
100
  end
97
101
 
102
+ return default unless options.count > 0
103
+
98
104
  CLI::UI::Prompt.ask(question, **opts) do |handler|
99
105
  handler.option(default_text.to_s) { default }
100
106
 
@@ -8,7 +8,7 @@ module CLI
8
8
  module VERSION
9
9
  RELEASE = 0
10
10
  MAJOR = 1
11
- MINOR = 0
11
+ MINOR = 1
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.1.0
4
+ version: 0.1.1
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-02-22 00:00:00.000000000 Z
11
+ date: 2019-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cli-ui
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '1.2'
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 1.2.1
22
+ version: 1.2.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '1.2'
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 1.2.1
32
+ version: 1.2.0
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: bundler
35
35
  requirement: !ruby/object:Gem::Requirement