planter-cli 3.0.3 → 3.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +14 -11
- data/bin/plant +1 -1
- data/lib/planter/version.rb +1 -1
- data/src/_README.md +14 -11
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06c272d8c938a24e24d8ad5ec220ba9100f6f35fbe6e8d9765a33c982607dbd0
|
4
|
+
data.tar.gz: f9a21781e985fce37c419fcf5f4e6f33cd13c951cd882468b6c90e3a19b50fdd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ffbd475e7f56a2c96cf325cd1a681e9a7541d191c9cc9f669c06e2b3a74b4c889b2256290c5b390ea36aa408bc5e262f605ed0106e4ec409b2dece751adbbcbc
|
7
|
+
data.tar.gz: cc9241c6c6ac2a10ac2d5b82cdf2e6c204472c18834b113499af57e18615706a429c2900d19bdb9aa287c2d77bbe0f0a0a22c29288c10fceb292d623a23c86c3
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -8,10 +8,6 @@ Plant a directory structure and files using templates.
|
|
8
8
|
|
9
9
|
If you run into errors, try `gem install --user-install planter-cli`, or as a last ditch effort, `sudo gem install planter-cli`.
|
10
10
|
|
11
|
-
### Optional
|
12
|
-
|
13
|
-
If [Gum](https://github.com/charmbracelet/gum) is available it will be used for command line input.
|
14
|
-
|
15
11
|
## Configuration
|
16
12
|
|
17
13
|
Planter's base configuration is in `~/.config/planter/planter.yml`. This file can contain any of the keys used in templates (see below) and will serve as a base configuration for all templates. Any key defined in this file will be overridden if it exists in a template.
|
@@ -37,7 +33,7 @@ Scripts can be executable files in any language, and receive the template direct
|
|
37
33
|
|
38
34
|
Templates are directories found in `~/.config/planter/templates/[TEMPLATE_NAME]`. All files and directories inside of these template directories are copied when that template is called. Filenames, directory names, and file contents can all use template placeholders.
|
39
35
|
|
40
|
-
Template placeholders are defined with `%%KEY%%`, where key is the key defined in the `variables` section of the configuration.
|
36
|
+
Template placeholders are defined with `%%KEY%%`, where key is the key defined in the `variables` section of the configuration. `%%KEY%%` placeholders can be used in directory/file names, and in the file contents. These work in any plain text or RTF format document, including XML, so they can be used in things like Scrivener templates and MindNode files as well.
|
41
37
|
|
42
38
|
Each template contains a `_planter.yml` file that defines variables and other configuration options. The file format for all configuration files is [YAML](https://yaml.org/spec/1.2.2/).
|
43
39
|
|
@@ -52,23 +48,28 @@ variables:
|
|
52
48
|
default: Untitled
|
53
49
|
min: 1
|
54
50
|
max: 5
|
51
|
+
```
|
52
|
+
|
53
|
+
A configuration can include additional keys:
|
54
|
+
|
55
|
+
```yaml
|
55
56
|
script: # array of scripts, args passed as [script and args] TEMPLATE_DIR PWD
|
56
57
|
- process.py
|
57
58
|
git_init: false # if true, initialize a git repository in the newly-planted directory
|
58
59
|
files: # Dictionary for file handling (see [File-specific handling](#file-specific-handling))
|
59
60
|
replacements: # Dictionary of pattern/replacments for regex substitution, see [Regex replacements](#regex-replacements)
|
60
|
-
repo: # If a repository URL is provided, it will be pulled and duplicated instead of copying
|
61
|
+
repo: # If a repository URL is provided, it will be pulled and duplicated instead of copying an existing file structure
|
61
62
|
```
|
62
63
|
|
63
64
|
#### Default values in template strings
|
64
65
|
|
65
|
-
In a template you can add a default value for a placholder by adding `%default value` to it. For example, `%%project%Default Project%%` will set the placeholder to `Default Project` if the variable value matches the default value in the configuration. This allows you to accept the default on the command line but have a different value inserted in the template. To use another variable in its place, use `$KEY` in the placeholder, e.g. `%%project%$title%%` will replace the `project` key with the value of `title` if the default is selected. Modifiers can be used on either side of the `%`, e.g. `%%project%$title:snake%%`.
|
66
|
+
In a template you can add a default value for a placholder by adding `%default value` to it. For example, `%%project%Default Project%%` will set the placeholder to `Default Project` if the variable value matches the default value in the configuration (or doesn't exist). This allows you to accept the default on the command line but have a different value inserted in the template. To use another variable in its place, use `$KEY` in the placeholder, e.g. `%%project%$title%%` will replace the `project` key with the value of `title` if the default is selected. Modifiers can be used on either side of the `%`, e.g. `%%project%$title:snake%%`.
|
66
67
|
|
67
68
|
#### Multiple choice type
|
68
69
|
|
69
70
|
If the `type` is set to `choice`, then the key `choices` can contain a hash or array of choices. The key that accepts the choice should be surrounded with parenthesis (required for each choice).
|
70
71
|
|
71
|
-
If a Hash is defined, each choice can have a result string:
|
72
|
+
If a Hash/Dictionary is defined, each choice can have a result string:
|
72
73
|
|
73
74
|
```yaml
|
74
75
|
variables:
|
@@ -84,7 +85,9 @@ variables:
|
|
84
85
|
(z)sh: "#! /bin/zsh"
|
85
86
|
```
|
86
87
|
|
87
|
-
|
88
|
+
When a choice is selected from a dictionary, the result string will be inserted instead of the choice title.
|
89
|
+
|
90
|
+
If an array is defined, the string of the choice will also be its result (minus any parenthesis):
|
88
91
|
|
89
92
|
```yaml
|
90
93
|
variables:
|
@@ -100,7 +103,7 @@ variables:
|
|
100
103
|
- 1. zsh
|
101
104
|
```
|
102
105
|
|
103
|
-
If the choice starts with a number (as above), then a numeric list will be generated and typing the associated index number will accept that choice. Numeric lists are automatically numbered, so the preceding digit doesn't matter, as long as it's a digit. In this case a default can be defined with an integer for its placement in the list (starting with 1), and parenthesis aren't required.
|
106
|
+
If the choice starts with a number (as above), then a numeric list will be generated and typing the associated index number will accept that choice. Numeric lists are automatically numbered, so the preceding digit doesn't matter, as long as it's a digit. In this case a default can be defined with an integer (in the `defaults:` key) for its placement in the list (starting with 1), and parenthesis aren't required.
|
104
107
|
|
105
108
|
#### If/then logic
|
106
109
|
|
@@ -196,7 +199,7 @@ If `preserve_tags` is set to `true` in the config (either base or template), the
|
|
196
199
|
The executable for Planter is `plant`. You can run `plant TEMPLATE` in any directory and TEMPLATE will be planted in the current directory. You can also use `--in PATH` to plant in another directory.
|
197
200
|
|
198
201
|
```
|
199
|
-
Usage:
|
202
|
+
Usage: plant [options] TEMPLATE
|
200
203
|
--defaults Accept default values for all variables
|
201
204
|
-i, --in TARGET Plant in TARGET instead of current directory
|
202
205
|
-o, --overwrite Overwrite existing files
|
data/bin/plant
CHANGED
@@ -26,7 +26,7 @@ Planter.base_dir = ENV['PLANTER_DIR'] || File.expand_path('~/.config/planter')
|
|
26
26
|
Planter::Color.coloring = $stdout.isatty
|
27
27
|
|
28
28
|
opts = OptionParser.new
|
29
|
-
opts.banner = 'Usage:
|
29
|
+
opts.banner = 'Usage: plant [options] TEMPLATE'
|
30
30
|
|
31
31
|
Planter.accept_defaults = false
|
32
32
|
opts.on('--defaults', 'Accept default values for all variables') do
|
data/lib/planter/version.rb
CHANGED
data/src/_README.md
CHANGED
@@ -13,10 +13,6 @@ Plant a directory structure and files using templates.
|
|
13
13
|
|
14
14
|
If you run into errors, try `gem install --user-install planter-cli`, or as a last ditch effort, `sudo gem install planter-cli`.
|
15
15
|
|
16
|
-
### Optional
|
17
|
-
|
18
|
-
If [Gum](https://github.com/charmbracelet/gum) is available it will be used for command line input.
|
19
|
-
|
20
16
|
## Configuration
|
21
17
|
|
22
18
|
Planter's base configuration is in `~/.config/planter/planter.yml`. This file can contain any of the keys used in templates (see below) and will serve as a base configuration for all templates. Any key defined in this file will be overridden if it exists in a template.
|
@@ -42,7 +38,7 @@ Scripts can be executable files in any language, and receive the template direct
|
|
42
38
|
|
43
39
|
Templates are directories found in `~/.config/planter/templates/[TEMPLATE_NAME]`. All files and directories inside of these template directories are copied when that template is called. Filenames, directory names, and file contents can all use template placeholders.
|
44
40
|
|
45
|
-
Template placeholders are defined with `%%KEY%%`, where key is the key defined in the `variables` section of the configuration.
|
41
|
+
Template placeholders are defined with `%%KEY%%`, where key is the key defined in the `variables` section of the configuration. `%%KEY%%` placeholders can be used in directory/file names, and in the file contents. These work in any plain text or RTF format document, including XML, so they can be used in things like Scrivener templates and MindNode files as well.
|
46
42
|
|
47
43
|
Each template contains a `_planter.yml` file that defines variables and other configuration options. The file format for all configuration files is [YAML](https://yaml.org/spec/1.2.2/).
|
48
44
|
|
@@ -57,23 +53,28 @@ variables:
|
|
57
53
|
default: Untitled
|
58
54
|
min: 1
|
59
55
|
max: 5
|
56
|
+
```
|
57
|
+
|
58
|
+
A configuration can include additional keys:
|
59
|
+
|
60
|
+
```yaml
|
60
61
|
script: # array of scripts, args passed as [script and args] TEMPLATE_DIR PWD
|
61
62
|
- process.py
|
62
63
|
git_init: false # if true, initialize a git repository in the newly-planted directory
|
63
64
|
files: # Dictionary for file handling (see [File-specific handling](#file-specific-handling))
|
64
65
|
replacements: # Dictionary of pattern/replacments for regex substitution, see [Regex replacements](#regex-replacements)
|
65
|
-
repo: # If a repository URL is provided, it will be pulled and duplicated instead of copying
|
66
|
+
repo: # If a repository URL is provided, it will be pulled and duplicated instead of copying an existing file structure
|
66
67
|
```
|
67
68
|
|
68
69
|
#### Default values in template strings
|
69
70
|
|
70
|
-
In a template you can add a default value for a placholder by adding `%default value` to it. For example, `%%project%Default Project%%` will set the placeholder to `Default Project` if the variable value matches the default value in the configuration. This allows you to accept the default on the command line but have a different value inserted in the template. To use another variable in its place, use `$KEY` in the placeholder, e.g. `%%project%$title%%` will replace the `project` key with the value of `title` if the default is selected. Modifiers can be used on either side of the `%`, e.g. `%%project%$title:snake%%`.
|
71
|
+
In a template you can add a default value for a placholder by adding `%default value` to it. For example, `%%project%Default Project%%` will set the placeholder to `Default Project` if the variable value matches the default value in the configuration (or doesn't exist). This allows you to accept the default on the command line but have a different value inserted in the template. To use another variable in its place, use `$KEY` in the placeholder, e.g. `%%project%$title%%` will replace the `project` key with the value of `title` if the default is selected. Modifiers can be used on either side of the `%`, e.g. `%%project%$title:snake%%`.
|
71
72
|
|
72
73
|
#### Multiple choice type
|
73
74
|
|
74
75
|
If the `type` is set to `choice`, then the key `choices` can contain a hash or array of choices. The key that accepts the choice should be surrounded with parenthesis (required for each choice).
|
75
76
|
|
76
|
-
If a Hash is defined, each choice can have a result string:
|
77
|
+
If a Hash/Dictionary is defined, each choice can have a result string:
|
77
78
|
|
78
79
|
```yaml
|
79
80
|
variables:
|
@@ -89,7 +90,9 @@ variables:
|
|
89
90
|
(z)sh: "#! /bin/zsh"
|
90
91
|
```
|
91
92
|
|
92
|
-
|
93
|
+
When a choice is selected from a dictionary, the result string will be inserted instead of the choice title.
|
94
|
+
|
95
|
+
If an array is defined, the string of the choice will also be its result (minus any parenthesis):
|
93
96
|
|
94
97
|
```yaml
|
95
98
|
variables:
|
@@ -105,7 +108,7 @@ variables:
|
|
105
108
|
- 1. zsh
|
106
109
|
```
|
107
110
|
|
108
|
-
If the choice starts with a number (as above), then a numeric list will be generated and typing the associated index number will accept that choice. Numeric lists are automatically numbered, so the preceding digit doesn't matter, as long as it's a digit. In this case a default can be defined with an integer for its placement in the list (starting with 1), and parenthesis aren't required.
|
111
|
+
If the choice starts with a number (as above), then a numeric list will be generated and typing the associated index number will accept that choice. Numeric lists are automatically numbered, so the preceding digit doesn't matter, as long as it's a digit. In this case a default can be defined with an integer (in the `defaults:` key) for its placement in the list (starting with 1), and parenthesis aren't required.
|
109
112
|
|
110
113
|
#### If/then logic
|
111
114
|
|
@@ -201,7 +204,7 @@ If `preserve_tags` is set to `true` in the config (either base or template), the
|
|
201
204
|
The executable for Planter is `plant`. You can run `plant TEMPLATE` in any directory and TEMPLATE will be planted in the current directory. You can also use `--in PATH` to plant in another directory.
|
202
205
|
|
203
206
|
```
|
204
|
-
Usage:
|
207
|
+
Usage: plant [options] TEMPLATE
|
205
208
|
--defaults Accept default values for all variables
|
206
209
|
-i, --in TARGET Plant in TARGET instead of current directory
|
207
210
|
-o, --overwrite Overwrite existing files
|