bashly 0.3.3 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +13 -12
- data/lib/bashly/commands/init.rb +1 -1
- data/lib/bashly/models/base.rb +1 -0
- data/lib/bashly/models/command.rb +2 -2
- data/lib/bashly/templates/minimal.yml +1 -1
- data/lib/bashly/templates/strings.yml +1 -0
- data/lib/bashly/version.rb +1 -1
- data/lib/bashly/views/command/usage_commands.erb +9 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7839064a69e5280ef2fcf0112ee9a4442912f99308a8c99dd3cf57c48fc905d2
|
4
|
+
data.tar.gz: '0923d678dd93f16ec6beb2bb796e679b355fe971fc7141910c5b62d025ccfc4b'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec45676addca44ee7ce775b505d368b29723ed689e890592608a96a36fc64f8570dfd15a2df3a82b6a7e4bd2081db6338d11de0b285488d4af8145a83205cdb1
|
7
|
+
data.tar.gz: cd6303a9834570a1d7a4a8d17ee796c72a116454cc1831af7a8897113419557840e1e1c94117abb06f9510dfb4b2aa4e7aafc67ce65eca2fcd0cd8ee56d0f8cd
|
data/README.md
CHANGED
@@ -41,11 +41,11 @@ Bahsly is responsible for:
|
|
41
41
|
|
42
42
|
- Generating a **single, standalone bash script**.
|
43
43
|
- Generating **usage texts** and help screens, showing your tool's arguments,
|
44
|
-
flags and
|
44
|
+
flags and commands (works for subcommands also).
|
45
45
|
- Parsing the user's command line and extracting:
|
46
46
|
- Optional or required **positional arguments**.
|
47
47
|
- Optional or required **option flags** (with or without flag arguments).
|
48
|
-
- **
|
48
|
+
- **Commands** (and subcommands).
|
49
49
|
- Standard flags (like **--help** and **--version**).
|
50
50
|
- Providing you with a place to input your code for each of the functions
|
51
51
|
your tool performs, and merging it back to the final script.
|
@@ -67,7 +67,7 @@ $ bashly init --minimal
|
|
67
67
|
```
|
68
68
|
|
69
69
|
This will create a sample `src/bashly.yml` file.
|
70
|
-
You can edit this file to specify which arguments, flags and
|
70
|
+
You can edit this file to specify which arguments, flags and commands you
|
71
71
|
need in your bash script.
|
72
72
|
|
73
73
|
Then, generate an initial bash script and function placeholder scripts by
|
@@ -92,24 +92,24 @@ Examples
|
|
92
92
|
|
93
93
|
The `bashly.yml` file can be set up to generate two types of scripts:
|
94
94
|
|
95
|
-
1. Script with
|
96
|
-
2. Script without
|
95
|
+
1. Script with commands (for example, like `docker` or `git`).
|
96
|
+
2. Script without commands (for example, like `ls`)
|
97
97
|
|
98
98
|
This is detected automatically by the contents of the configuration: If it
|
99
|
-
contains a `commands` definition, it will generate a script with
|
99
|
+
contains a `commands` definition, it will generate a script with commands.
|
100
100
|
|
101
101
|
|
102
|
-
### Sample configuraiton for a script without
|
102
|
+
### Sample configuraiton for a script without commands
|
103
103
|
|
104
104
|
- Generate this script by running `bashly generate --minimal`
|
105
105
|
- [See the initial sample bashly.yml file](examples/minimal/src/bashly.yml)
|
106
106
|
- [See the generated bash script](examples/minimal/download)
|
107
107
|
|
108
|
-
### Sample configuraiton for a script with
|
108
|
+
### Sample configuraiton for a script with commands
|
109
109
|
|
110
110
|
- Generate this script by running `bashly generate`
|
111
|
-
- [See the initial sample bashly.yml file](examples/
|
112
|
-
- [See the generated bash script](examples/
|
111
|
+
- [See the initial sample bashly.yml file](examples/commands/src/bashly.yml)
|
112
|
+
- [See the generated bash script](examples/commands/cli)
|
113
113
|
|
114
114
|
|
115
115
|
See the [examples](examples) folder for more examples.
|
@@ -140,13 +140,14 @@ command and subcommands (under the `commands` definition).
|
|
140
140
|
`short` | An additional, optional pattern - usually used to denote a one letter variation of the command name. You can add `*` as a suffix, to denote a "starts with" pattern - for example `short: m*`. *Applicable only in subcommands*.
|
141
141
|
`help` | The header text to display when using `--help`. This option can have multiple lines. In this case, the first line will be used as summary wherever appropriate.
|
142
142
|
`version` | The string to display when using `--version`. *Applicable only in the main command*.
|
143
|
-
`default` | Setting this to `yes` on any
|
143
|
+
`default` | Setting this to `yes` on any command, will make unrecognized command line arguments to be passed to this command. *Applicable only in subcommands*.
|
144
144
|
`examples` | Specify an array of examples to show when using `--help`. Each example can have multiple lines.
|
145
145
|
`environment_variables` | Specify an array of environment variables needed by your script.
|
146
|
-
`commands` | Specify the array of
|
146
|
+
`commands` | Specify the array of commands. Each command will have its own args and flags. Note: if `commands` is provided, you cannot specify flags or args at the same level.
|
147
147
|
`args` | Specify the array of positional arguments this script needs.
|
148
148
|
`flags` | Specify the array of option flags this script needs.
|
149
149
|
`dependencies` | Specify an array of any required external dependencies (commands). The script execution will be halted with a friendly error unless all dependency commands exist.
|
150
|
+
`group` | In case you have many commands, use this option to specify a caption to display before this command. This option is purely for display purposes, and needs to be specified only for the first command in each group.
|
150
151
|
|
151
152
|
### Argument options
|
152
153
|
|
data/lib/bashly/commands/init.rb
CHANGED
@@ -7,7 +7,7 @@ module Bashly
|
|
7
7
|
usage "bashly init [--minimal]"
|
8
8
|
usage "bashly init (-h|--help)"
|
9
9
|
|
10
|
-
option "-m --minimal", "Use a minimal configuration file (without
|
10
|
+
option "-m --minimal", "Use a minimal configuration file (without commands)"
|
11
11
|
|
12
12
|
environment "BASHLY_SOURCE_DIR", "The path to use for creating the configuration file [default: src]"
|
13
13
|
|
data/lib/bashly/models/base.rb
CHANGED
@@ -28,12 +28,12 @@ module Bashly
|
|
28
28
|
help ? "#{full_name} - #{summary}" : full_name
|
29
29
|
end
|
30
30
|
|
31
|
-
# Returns only the names of the
|
31
|
+
# Returns only the names of the Commands
|
32
32
|
def command_names
|
33
33
|
commands.map &:name
|
34
34
|
end
|
35
35
|
|
36
|
-
# Returns an array of the
|
36
|
+
# Returns an array of the Commands
|
37
37
|
def commands
|
38
38
|
return [] unless options["commands"]
|
39
39
|
options["commands"].map do |options|
|
data/lib/bashly/version.rb
CHANGED
@@ -1,9 +1,18 @@
|
|
1
1
|
# :command.usage_commands
|
2
|
+
<%- unless commands.first.group -%>
|
2
3
|
printf "<%= strings[:commands] %>\n"
|
4
|
+
<%- end -%>
|
3
5
|
<%- maxlen = command_names.map(&:size).max -%>
|
4
6
|
<%- commands.each do |command| -%>
|
5
7
|
<%- summary = command.summary -%>
|
6
8
|
<%- summary = strings[:default_command_summary] % { summary: summary } if command.default -%>
|
9
|
+
<%- if command.group -%>
|
10
|
+
<%- if command.name == commands.first.name -%>
|
11
|
+
printf "<%= strings[:group] % { group: command.group } %>\n"
|
12
|
+
<%- else -%>
|
13
|
+
printf "\n<%= strings[:group] % { group: command.group } %>\n"
|
14
|
+
<%- end -%>
|
15
|
+
<%- end -%>
|
7
16
|
echo " <%= command.name.ljust maxlen %> <%= summary %>"
|
8
17
|
<%- end -%>
|
9
18
|
echo
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bashly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danny Ben Shitrit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-12-
|
11
|
+
date: 2019-12-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colsole
|