bake 0.14.1 → 0.14.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bake/version.rb +1 -1
- metadata +5 -18
- data/.github/workflows/development.yml +0 -35
- data/.gitignore +0 -13
- data/.rspec +0 -3
- data/README.md +0 -61
- data/bake.gemspec +0 -29
- data/bake.rb +0 -0
- data/gems.rb +0 -11
- data/guides/command-line-interface/README.md +0 -55
- data/guides/gem-integration/README.md +0 -69
- data/guides/getting-started/README.md +0 -109
- data/guides/links.yaml +0 -8
- data/guides/project-integration/README.md +0 -64
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b596d8fcdd2daa879fedc00f65aac1696b04b40ab1a727d7617566411557c730
|
4
|
+
data.tar.gz: 8281d5f3337188820811cb3ecf4a4b735fb517e90222c8a2c82e0fb3ce8d59de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9419bc5577aa2765bd15232d5bd2340b6b92584f795480d874800b4d163b25623a96291fbfa853317079e7de0e481b8b960bf5ecae0cd653c6743369a4f8fdda
|
7
|
+
data.tar.gz: 96b4996147f6c8a3fe4408c8027f2a407d431de472445a1739e096d08353117ced32bf02e9a07470f50248011d7fc506f20bb5e886e26dc6a0ab4b09efb0f5cd
|
data/lib/bake/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.14.
|
4
|
+
version: 0.14.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: samovar
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: covered
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -68,25 +68,12 @@ dependencies:
|
|
68
68
|
version: '0'
|
69
69
|
description:
|
70
70
|
email:
|
71
|
-
- samuel.williams@oriontransfer.co.nz
|
72
71
|
executables:
|
73
72
|
- bake
|
74
73
|
extensions: []
|
75
74
|
extra_rdoc_files: []
|
76
75
|
files:
|
77
|
-
- ".github/workflows/development.yml"
|
78
|
-
- ".gitignore"
|
79
|
-
- ".rspec"
|
80
|
-
- README.md
|
81
|
-
- bake.gemspec
|
82
|
-
- bake.rb
|
83
76
|
- bin/bake
|
84
|
-
- gems.rb
|
85
|
-
- guides/command-line-interface/README.md
|
86
|
-
- guides/gem-integration/README.md
|
87
|
-
- guides/getting-started/README.md
|
88
|
-
- guides/links.yaml
|
89
|
-
- guides/project-integration/README.md
|
90
77
|
- lib/bake.rb
|
91
78
|
- lib/bake/base.rb
|
92
79
|
- lib/bake/command.rb
|
@@ -118,7 +105,7 @@ homepage: https://github.com/ioquatix/bake
|
|
118
105
|
licenses:
|
119
106
|
- MIT
|
120
107
|
metadata:
|
121
|
-
|
108
|
+
funding_uri: https://github.com/sponsors/ioquatix/
|
122
109
|
post_install_message:
|
123
110
|
rdoc_options: []
|
124
111
|
require_paths:
|
@@ -1,35 +0,0 @@
|
|
1
|
-
name: Development
|
2
|
-
|
3
|
-
on: [push]
|
4
|
-
|
5
|
-
jobs:
|
6
|
-
test:
|
7
|
-
strategy:
|
8
|
-
matrix:
|
9
|
-
os:
|
10
|
-
- ubuntu
|
11
|
-
- macos
|
12
|
-
|
13
|
-
ruby:
|
14
|
-
- 2.5
|
15
|
-
- 2.6
|
16
|
-
- 2.7
|
17
|
-
|
18
|
-
include:
|
19
|
-
- os: 'ubuntu'
|
20
|
-
ruby: '2.6'
|
21
|
-
env: COVERAGE=PartialSummary,Coveralls
|
22
|
-
|
23
|
-
runs-on: ${{matrix.os}}-latest
|
24
|
-
|
25
|
-
steps:
|
26
|
-
- uses: actions/checkout@v1
|
27
|
-
- uses: actions/setup-ruby@v1
|
28
|
-
with:
|
29
|
-
ruby-version: ${{matrix.ruby}}
|
30
|
-
- name: Install dependencies
|
31
|
-
run: |
|
32
|
-
command -v bundler || gem install bundler
|
33
|
-
bundle install
|
34
|
-
- name: Run tests
|
35
|
-
run: ${{matrix.env}} bundle exec rspec
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/README.md
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
# Bake
|
2
|
-
|
3
|
-
Bake is a task execution tool, inspired by Rake, but codifying many of the use cases which are typically implemented in an ad-hoc manner.
|
4
|
-
|
5
|
-
[![Development](https://github.com/ioquatix/bake/workflows/Development/badge.svg)](https://github.com/ioquatix/bake/actions?workflow=Development)
|
6
|
-
|
7
|
-
## Features
|
8
|
-
|
9
|
-
Rake is an awesome tool and loved by the community. So, why reinvent it? Bake provides the following features that Rake does not:
|
10
|
-
|
11
|
-
- On demand loading of files following a standard convention. This avoid loading all your rake tasks just to execute a single command.
|
12
|
-
- Better argument handling including support for positional and optional arguments.
|
13
|
-
- Focused on task execution not dependency resolution. Implementation is simpler and a bit more predictable.
|
14
|
-
- Canonical structure for integration with gems.
|
15
|
-
|
16
|
-
That being said, Rake and Bake can exist side by side in the same project.
|
17
|
-
|
18
|
-
## Usage
|
19
|
-
|
20
|
-
Please see the [project documentation](https://ioquatix.github.io/bake/).
|
21
|
-
|
22
|
-
## Contributing
|
23
|
-
|
24
|
-
We welcome contributions to this project.
|
25
|
-
|
26
|
-
1. Fork it.
|
27
|
-
2. Create your feature branch (`git checkout -b my-new-feature`).
|
28
|
-
3. Commit your changes (`git commit -am 'Add some feature'`).
|
29
|
-
4. Push to the branch (`git push origin my-new-feature`).
|
30
|
-
5. Create new Pull Request.
|
31
|
-
|
32
|
-
|
33
|
-
## See Also
|
34
|
-
|
35
|
-
- [Console](https://github.com/socketry/console) — A logging framework which integrates with bake.
|
36
|
-
- [Variant](https://github.com/socketry/variant) — A framework for selecting different environments, including bake tasks.
|
37
|
-
- [Utopia](https://github.com/socketry/utopia) — A website framework which uses bake for maintenance tasks.
|
38
|
-
|
39
|
-
## License
|
40
|
-
|
41
|
-
Released under the MIT license.
|
42
|
-
|
43
|
-
Copyright, 2020, by [Samuel G. D. Williams](http://www.codeotaku.com).
|
44
|
-
|
45
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
46
|
-
of this software and associated documentation files (the "Software"), to deal
|
47
|
-
in the Software without restriction, including without limitation the rights
|
48
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
49
|
-
copies of the Software, and to permit persons to whom the Software is
|
50
|
-
furnished to do so, subject to the following conditions:
|
51
|
-
|
52
|
-
The above copyright notice and this permission notice shall be included in
|
53
|
-
all copies or substantial portions of the Software.
|
54
|
-
|
55
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
56
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
57
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
58
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
59
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
60
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
61
|
-
THE SOFTWARE.
|
data/bake.gemspec
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
require_relative 'lib/bake/version'
|
2
|
-
|
3
|
-
Gem::Specification.new do |spec|
|
4
|
-
spec.name = "bake"
|
5
|
-
spec.version = Bake::VERSION
|
6
|
-
spec.authors = ["Samuel Williams"]
|
7
|
-
spec.email = ["samuel.williams@oriontransfer.co.nz"]
|
8
|
-
|
9
|
-
spec.summary = "A replacement for rake with a simpler syntax."
|
10
|
-
spec.homepage = "https://github.com/ioquatix/bake"
|
11
|
-
spec.license = "MIT"
|
12
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
|
13
|
-
|
14
|
-
spec.metadata["donation_uri"] = "https://github.com/sponsors/ioquatix"
|
15
|
-
|
16
|
-
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
17
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(docs|test|spec|features)/}) }
|
18
|
-
end
|
19
|
-
|
20
|
-
spec.bindir = "bin"
|
21
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
22
|
-
spec.require_paths = ["lib"]
|
23
|
-
|
24
|
-
spec.add_dependency 'samovar', '~> 2.1'
|
25
|
-
|
26
|
-
spec.add_development_dependency 'covered'
|
27
|
-
spec.add_development_dependency 'bundler'
|
28
|
-
spec.add_development_dependency 'rspec'
|
29
|
-
end
|
data/bake.rb
DELETED
File without changes
|
data/gems.rb
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
# Command Line Interface
|
2
|
-
|
3
|
-
The `bake` command is broken up into two main functions: `list` and `call`.
|
4
|
-
|
5
|
-
<pre>% bake --help
|
6
|
-
<b>bake [-h/--help] [-b/--bakefile <path>] <command></b>
|
7
|
-
<font color="#638FFF">Execute tasks using Ruby.</font>
|
8
|
-
|
9
|
-
[-h/--help] Show help.
|
10
|
-
[-b/--bakefile <path>] Override the path to the bakefile to use.
|
11
|
-
<command> One of: call, list. (default: call)
|
12
|
-
|
13
|
-
<b>call <commands...></b>
|
14
|
-
<font color="#638FFF">Execute one or more commands.</font>
|
15
|
-
|
16
|
-
<commands...> The commands & arguments to invoke. (default: ["default"])
|
17
|
-
|
18
|
-
<b>list <pattern></b>
|
19
|
-
<pattern> The pattern to filter tasks by.
|
20
|
-
</pre>
|
21
|
-
|
22
|
-
## List
|
23
|
-
|
24
|
-
The `bake list` command allows you to list all available recipes. By proving a pattern you will only see recipes that have a matching command name.
|
25
|
-
|
26
|
-
<pre>$ bake list console
|
27
|
-
<b>Bake::Loader console-1.8.2</b>
|
28
|
-
|
29
|
-
<b>console:info</b>
|
30
|
-
<font color="#638FFF">Increase the verbosity of the logger to info.</font>
|
31
|
-
|
32
|
-
<b>console:debug</b>
|
33
|
-
<font color="#638FFF">Increase the verbosity of the logger to debug.</font>
|
34
|
-
</pre>
|
35
|
-
|
36
|
-
The listing documents positional and optional arguments. The documentation is generated from the comments in the bakefiles.
|
37
|
-
|
38
|
-
## Call
|
39
|
-
|
40
|
-
The `bake call` (the default, so `call` can be omitted) allows you to execute one or more recipes. You must provide the name of the command, followed by any arguments.
|
41
|
-
|
42
|
-
<pre>$ bake async:http:head https://www.codeotaku.com/index
|
43
|
-
<font color="#638FFF"><b> HEAD</b></font>: https://www.codeotaku.com/index
|
44
|
-
<font color="#00AA00"><b> version</b></font>: h2
|
45
|
-
<font color="#00AA00"><b> status</b></font>: 200
|
46
|
-
<font color="#00AA00"><b> body</b></font>: body with length <b>7879B</b>
|
47
|
-
<b> content-type</b>: "text/html; charset=utf-8"
|
48
|
-
<b> cache-control</b>: "public, max-age=3600"
|
49
|
-
<b> expires</b>: "Mon, 04 May 2020 13:23:47 GMT"
|
50
|
-
<b> server</b>: "falcon/0.36.4"
|
51
|
-
<b> date</b>: "Mon, 04 May 2020 12:23:47 GMT"
|
52
|
-
<b> vary</b>: "accept-encoding"
|
53
|
-
</pre>
|
54
|
-
|
55
|
-
You can specify multiple commands and they will be executed sequentially.
|
@@ -1,69 +0,0 @@
|
|
1
|
-
# Gem Integration
|
2
|
-
|
3
|
-
This guide explains how to add `bake` to a Ruby gem and export standardised tasks for use by other gems and projects.
|
4
|
-
|
5
|
-
## Exporting Tasks
|
6
|
-
|
7
|
-
Adding a `bake/` directory to your gem will allow other gems and projects to consume those recipes. In order to prevent collisions, you *should* prefix your commands with the name of the gem, e.g. in `mygem/bake/mygem.rb`:
|
8
|
-
|
9
|
-
~~~ ruby
|
10
|
-
def setup
|
11
|
-
# ...
|
12
|
-
end
|
13
|
-
~~~
|
14
|
-
|
15
|
-
Then, in a different project which depends on `mygem`, you can run tasks from `mygem` by invoking them using `bake`:
|
16
|
-
|
17
|
-
~~~ bash
|
18
|
-
$ bake mygem:setup
|
19
|
-
~~~
|
20
|
-
|
21
|
-
## Examples
|
22
|
-
|
23
|
-
There are many gems which export tasks in this way. Here are some notable examples:
|
24
|
-
|
25
|
-
### Variant
|
26
|
-
|
27
|
-
The [variant gem](https://github.com/socketry/variant) exposes bake tasks for setting the environment e.g. `development`, `testing`, or `production`.
|
28
|
-
|
29
|
-
<pre class="terminal">$ bake list variant
|
30
|
-
<b>Bake::Loader variant-0.1.1</b>
|
31
|
-
|
32
|
-
<b>variant:production</b> <font color="#00AA00">**overrides</font>
|
33
|
-
<font color="#638FFF">Select the production variant.</font>
|
34
|
-
<font color="#00AA00">overrides</font> [Hash] <font color="#638FFF">any specific variant overrides.</font>
|
35
|
-
|
36
|
-
<b>variant:staging</b> <font color="#00AA00">**overrides</font>
|
37
|
-
<font color="#638FFF">Select the staging variant.</font>
|
38
|
-
<font color="#00AA00">overrides</font> [Hash] <font color="#638FFF">any specific variant overrides.</font>
|
39
|
-
|
40
|
-
<b>variant:development</b> <font color="#00AA00">**overrides</font>
|
41
|
-
<font color="#638FFF">Select the development variant.</font>
|
42
|
-
<font color="#00AA00">overrides</font> [Hash] <font color="#638FFF">any specific variant overrides.</font>
|
43
|
-
|
44
|
-
<b>variant:testing</b> <font color="#00AA00">**overrides</font>
|
45
|
-
<font color="#638FFF">Select the testing variant.</font>
|
46
|
-
<font color="#00AA00">overrides</font> [Hash] <font color="#638FFF">any specific variant overrides.</font>
|
47
|
-
|
48
|
-
<b>variant:force</b> <font color="#AA0000">name</font> <font color="#00AA00">**overrides</font>
|
49
|
-
<font color="#638FFF">Force a specific variant.</font>
|
50
|
-
<font color="#00AA00">name</font> [Symbol] <font color="#638FFF">the default variant.</font>
|
51
|
-
<font color="#00AA00">overrides</font> [Hash] <font color="#638FFF">any specific variant overrides.</font>
|
52
|
-
|
53
|
-
<b>variant:show</b>
|
54
|
-
<font color="#638FFF">Show variant-related environment variables.</font>
|
55
|
-
</pre>
|
56
|
-
|
57
|
-
### Console
|
58
|
-
|
59
|
-
The [console gem](https://github.com/socketry/console) exposes bake tasks to change the log level.
|
60
|
-
|
61
|
-
<pre class="terminal">$ bake list console
|
62
|
-
<b>Bake::Loader console-1.8.2</b>
|
63
|
-
|
64
|
-
<b>console:info</b>
|
65
|
-
<font color="#638FFF">Increase the verbosity of the logger to info.</font>
|
66
|
-
|
67
|
-
<b>console:debug</b>
|
68
|
-
<font color="#638FFF">Increase the verbosity of the logger to debug.</font>
|
69
|
-
</pre>
|
@@ -1,109 +0,0 @@
|
|
1
|
-
# Getting Started
|
2
|
-
|
3
|
-
This guide gives a general overview of `bake` and how to use it.
|
4
|
-
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
Add the gem to your project:
|
8
|
-
|
9
|
-
~~~ bash
|
10
|
-
$ bundle add bake
|
11
|
-
~~~
|
12
|
-
|
13
|
-
## Core Concepts
|
14
|
-
|
15
|
-
`bake` has several core concepts:
|
16
|
-
|
17
|
-
- A `bake` executable used for invoking one or more tasks.
|
18
|
-
- A {ruby Bake::Context} instance which is bound to a project or gem and exposes a hierarchy of runnable tasks.
|
19
|
-
- A {ruby Bake::Loaders} instance which is used for on-demand loading of bake files from the current project and all available gems.
|
20
|
-
|
21
|
-
## Executing Tasks
|
22
|
-
|
23
|
-
The `bake` executable can be used to execute tasks in a `bake.rb` file in the same directory.
|
24
|
-
|
25
|
-
``` ruby
|
26
|
-
# bake.rb
|
27
|
-
|
28
|
-
def add(x, y)
|
29
|
-
puts Integer(x) + Integer(y)
|
30
|
-
end
|
31
|
-
```
|
32
|
-
|
33
|
-
You can execute this task from the command line:
|
34
|
-
|
35
|
-
``` shell
|
36
|
-
% bake add 10 20
|
37
|
-
30
|
38
|
-
```
|
39
|
-
|
40
|
-
### Using Types
|
41
|
-
|
42
|
-
You can annotate your task with a type signature and `bake` will coerce your arguments to these types:
|
43
|
-
|
44
|
-
``` ruby
|
45
|
-
# bake.rb
|
46
|
-
|
47
|
-
# @parameter x [Integer]
|
48
|
-
# @parameter y [Integer]
|
49
|
-
def add(x, y)
|
50
|
-
puts x + y
|
51
|
-
end
|
52
|
-
```
|
53
|
-
|
54
|
-
You can execute this task from the command line:
|
55
|
-
|
56
|
-
``` shell
|
57
|
-
% bake add 10 20
|
58
|
-
30
|
59
|
-
```
|
60
|
-
|
61
|
-
The values are automatically coerced to `Integer`.
|
62
|
-
|
63
|
-
### Extending With Documentation
|
64
|
-
|
65
|
-
You can add documentation to your tasks and parameters (using Markdown formatting).
|
66
|
-
|
67
|
-
``` ruby
|
68
|
-
# bake.rb
|
69
|
-
|
70
|
-
# Add the x and y coordinate together and print the result.
|
71
|
-
# @parameter x [Integer] The x offset.
|
72
|
-
# @parameter y [Integer] The y offset.
|
73
|
-
def add(x, y)
|
74
|
-
puts x + y
|
75
|
-
end
|
76
|
-
```
|
77
|
-
|
78
|
-
You can see this documentation in the task listing:
|
79
|
-
|
80
|
-
``` shell
|
81
|
-
% bake list add
|
82
|
-
Bake::Context getting-started
|
83
|
-
|
84
|
-
add x y
|
85
|
-
Add the x and y coordinate together and print the result.
|
86
|
-
x [Integer] The x offset.
|
87
|
-
y [Integer] The y offset.
|
88
|
-
```
|
89
|
-
|
90
|
-
### Private Methods
|
91
|
-
|
92
|
-
If you want to add helper methods which don't show up as tasks, define them as `protected` or `private`.
|
93
|
-
|
94
|
-
``` ruby
|
95
|
-
# bake.rb
|
96
|
-
|
97
|
-
# Add the x and y coordinate together and print the result.
|
98
|
-
# @parameter x [Integer] The x offset.
|
99
|
-
# @parameter y [Integer] The y offset.
|
100
|
-
def add(x, y)
|
101
|
-
puts x + y
|
102
|
-
end
|
103
|
-
|
104
|
-
private
|
105
|
-
|
106
|
-
def puts(*arguments)
|
107
|
-
$stdout.puts arguments.inspect
|
108
|
-
end
|
109
|
-
```
|
data/guides/links.yaml
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
# Project Integration
|
2
|
-
|
3
|
-
This guide explains how to add `bake` to a Ruby project.
|
4
|
-
|
5
|
-
## Bakefile
|
6
|
-
|
7
|
-
At the top level of your project, you can create a `bake.rb` file, which contains top level tasks which are private to your project.
|
8
|
-
|
9
|
-
~~~ ruby
|
10
|
-
def cake
|
11
|
-
ingredients = call 'supermarket:shop', 'flour,sugar,cocoa'
|
12
|
-
lookup('mixer:add').call(ingredients)
|
13
|
-
end
|
14
|
-
~~~
|
15
|
-
|
16
|
-
This file is project specific and is the only file which can expose top level tasks (i.e. without a defined namespace). When used in a gem, these tasks are not exposed to other gems/projects.
|
17
|
-
|
18
|
-
## Recipes
|
19
|
-
|
20
|
-
Alongside the `bake.rb`, there is a `bake/` directory which contains files like `supermarket.rb`. These files contain recipes, e.g.:
|
21
|
-
|
22
|
-
~~~ ruby
|
23
|
-
# @param ingredients [Array(Any)] the ingredients to purchase.
|
24
|
-
def shop(ingredients)
|
25
|
-
supermarket = Supermarket.best
|
26
|
-
|
27
|
-
return supermarket.purchase(ingredients)
|
28
|
-
end
|
29
|
-
~~~
|
30
|
-
|
31
|
-
These methods are automatically scoped according to the file name, e.g. `bake/supermarket.rb` will define `supermarket:shop`.
|
32
|
-
|
33
|
-
|
34
|
-
## Arguments
|
35
|
-
|
36
|
-
Arguments work as normal. Documented types are used to parse strings from the command line. Both positional and optional parameters are supported.
|
37
|
-
|
38
|
-
### Positional Parameters
|
39
|
-
|
40
|
-
Positional parameters are non-keyword parameters which may have a default value. However, because of the limits of the command line, all positional arguments must be specified.
|
41
|
-
|
42
|
-
~~~ ruby
|
43
|
-
# @param x [Integer]
|
44
|
-
# @param y [Integer]
|
45
|
-
def add(x, y)
|
46
|
-
puts x + y
|
47
|
-
end
|
48
|
-
~~~
|
49
|
-
|
50
|
-
Which is invoked by `bake add 1 2`.
|
51
|
-
|
52
|
-
### Optional Parameters
|
53
|
-
|
54
|
-
Optional parameters are keyword parameters which may have a default value. The parameter is set on the command line using the name of the parameter followed by an equals sign, followed by the value.
|
55
|
-
|
56
|
-
~~~ ruby
|
57
|
-
# @param x [Integer]
|
58
|
-
# @param y [Integer]
|
59
|
-
def add(x:, y: 2)
|
60
|
-
puts x + y
|
61
|
-
end
|
62
|
-
~~~
|
63
|
-
|
64
|
-
Which is invoked by `bake add x=1`. Because `y` is not specified, it will default to `2` as per the method definition.
|