bashly 0.6.3 → 0.6.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 +47 -2
- data/lib/bashly/models/command.rb +13 -2
- data/lib/bashly/version.rb +1 -1
- data/lib/bashly/views/command/catch_all_filter.erb +7 -0
- data/lib/bashly/views/command/fixed_flags_filter.erb +1 -1
- data/lib/bashly/views/command/parse_requirements.erb +1 -0
- data/lib/bashly.rb +0 -1
- metadata +3 -3
- data/lib/bashly/polyfills/hash.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 650f456561f180e0a39b2e6e0c66f6c5913438ac6301d44bff064470d602daba
|
4
|
+
data.tar.gz: 2f64d00edb50ce738d506568600d8b73b898aad6563990460a80a52d912a6e66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70427709c22c05bcfdfadb1daafaea8c87c5854b03488913c916ffb29861521c853eb5392f22c0c79b7bdc8fe359fc55389c0d6f0540493c250dd6ba1f7d79b5
|
7
|
+
data.tar.gz: 2b2aa5dc0525edc81ce3c023583b0d829907de9e1656a00fdb37d6cd87e0b4ab788e70e71fe51763a661006f8ce8fdf950a7c3e7ffcce095edec5cc799e942ed
|
data/README.md
CHANGED
@@ -3,22 +3,66 @@
|
|
3
3
|
|
4
4
|
# Bashly - Bash CLI Framework and Generator
|
5
5
|
|
6
|
-
Create
|
6
|
+
Create feature-rich bash scripts using simple YAML configuration
|
7
7
|
|
8
8
|
[](https://badge.fury.io/rb/bashly)
|
9
9
|
[](https://github.com/DannyBen/bashly/actions?query=workflow%3ATest)
|
10
10
|
[](https://codeclimate.com/github/DannyBen/bashly/maintainability)
|
11
11
|
|
12
|
+
## [bashly.dannyb.co](https://bashly.dannyb.co)
|
13
|
+
|
12
14
|
---
|
13
15
|
|
14
16
|

|
15
17
|
|
16
18
|
</div>
|
17
19
|
|
20
|
+
Bashly is a command line application (written in Ruby) that lets you
|
21
|
+
generate feature-rich bash command line tools.
|
22
|
+
|
23
|
+
Bashly lets you focus on your specific code, without worrying about command line
|
24
|
+
argument parsing, usage texts, error messages and other functions that are
|
25
|
+
usually handled by a framework in any other programming language.
|
26
|
+
|
27
|
+
It is available both as a [ruby gem](https://rubygems.org/gems/bashly) and as
|
28
|
+
a [docker image](https://hub.docker.com/r/dannyben/bashly).
|
29
|
+
|
30
|
+
|
18
31
|
## Documentation
|
19
32
|
|
20
|
-
|
33
|
+
- [Bashly Homepage][docs]
|
34
|
+
- [Examples][examples]
|
35
|
+
|
36
|
+
## How it works
|
37
|
+
|
38
|
+
1. You provide a YAML configuration file, describing commands, sub-commands,
|
39
|
+
arguments, and flags. Running `bashly init` creates an initial sample YAML
|
40
|
+
file for you ([example](https://github.com/DannyBen/bashly/tree/master/examples/minimal#bashlyyml)).
|
41
|
+
2. Bashly then automatically generates a bash script (when you run
|
42
|
+
`bashly generate`) that can parse and validate user input, provide help
|
43
|
+
messages, and run your code for each command ([example](https://github.com/DannyBen/bashly/blob/master/examples/minimal/download)).
|
44
|
+
3. Your code for each command is kept in a separate file, and can be merged
|
45
|
+
again if you change it ([example](https://github.com/DannyBen/bashly/blob/master/examples/minimal/src/root_command.sh)).
|
46
|
+
|
47
|
+
## Features
|
48
|
+
|
49
|
+
Bashly is responsible for:
|
21
50
|
|
51
|
+
- Generating a **single, standalone bash script**.
|
52
|
+
- Generating **usage texts** and help screens, showing your tool's arguments, flags and commands (works for sub-commands also).
|
53
|
+
- Parsing the user's command line and extracting:
|
54
|
+
- Optional or required **positional arguments**.
|
55
|
+
- Optional or required **option flags** (with or without flag arguments).
|
56
|
+
- **Commands** (and sub-commands).
|
57
|
+
- Standard flags (like **--help** and **--version**).
|
58
|
+
- Preventing your script from running unless the command line is valid.
|
59
|
+
- Providing you with a place to input your code for each of the functions your tool performs, and merging it back to the final script.
|
60
|
+
- Providing you with additional (optional) framework-style, standard library functions:
|
61
|
+
- **Color output**.
|
62
|
+
- **Config file management** (INI format).
|
63
|
+
- **YAML parsing**.
|
64
|
+
- **Bash completions**.
|
65
|
+
- and more.
|
22
66
|
|
23
67
|
## Contributing / Support
|
24
68
|
|
@@ -29,4 +73,5 @@ to contribute, feel free to [open an issue][issues].
|
|
29
73
|
|
30
74
|
[issues]: https://github.com/DannyBen/bashly/issues
|
31
75
|
[docs]: https://bashly.dannyb.co/
|
76
|
+
[examples]: https://github.com/DannyBen/bashly/tree/master/examples#bashly-examples
|
32
77
|
|
@@ -5,7 +5,7 @@ module Bashly
|
|
5
5
|
|
6
6
|
# Returns the name to be used as an action.
|
7
7
|
# - If it is the root command, the action is "root"
|
8
|
-
# - Else, it is all the parents, except the first
|
8
|
+
# - Else, it is all the parents, except the first one (root) joined
|
9
9
|
# by space. For example, for a command like "docker container run"
|
10
10
|
# the action name is "container run".
|
11
11
|
def action_name
|
@@ -54,6 +54,17 @@ module Bashly
|
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
+
# Returns true if catch_all is required
|
58
|
+
def catch_all_required?
|
59
|
+
catch_all.is_a?(Hash) and catch_all['required']
|
60
|
+
end
|
61
|
+
|
62
|
+
# Returns a string suitable for catch_all Usage pattern
|
63
|
+
def catch_all_usage
|
64
|
+
return nil unless catch_all
|
65
|
+
catch_all_required? ? catch_all_label : "[#{catch_all_label}]"
|
66
|
+
end
|
67
|
+
|
57
68
|
# Returns only the names of the Commands
|
58
69
|
def command_names
|
59
70
|
commands.map &:name
|
@@ -190,7 +201,7 @@ module Bashly
|
|
190
201
|
result << arg.usage_string
|
191
202
|
end
|
192
203
|
result << "[options]" unless flags.empty?
|
193
|
-
result <<
|
204
|
+
result << catch_all_usage if catch_all
|
194
205
|
result.join " "
|
195
206
|
end
|
196
207
|
|
data/lib/bashly/version.rb
CHANGED
@@ -11,6 +11,7 @@ parse_requirements() {
|
|
11
11
|
<%= render(:required_args_filter).indent 2 %>
|
12
12
|
<%= render(:required_flags_filter).indent 2 %>
|
13
13
|
<%= render(:parse_requirements_while).indent 2 %>
|
14
|
+
<%= render(:catch_all_filter).indent 2 %>
|
14
15
|
<%= render(:default_assignments).indent 2 %>
|
15
16
|
<%= render(:whitelist_filter).indent 2 %>
|
16
17
|
}
|
data/lib/bashly.rb
CHANGED
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.6.
|
4
|
+
version: 0.6.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: 2021-08-
|
11
|
+
date: 2021-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colsole
|
@@ -102,7 +102,6 @@ files:
|
|
102
102
|
- lib/bashly/models/environment_variable.rb
|
103
103
|
- lib/bashly/models/flag.rb
|
104
104
|
- lib/bashly/models/script.rb
|
105
|
-
- lib/bashly/polyfills/hash.rb
|
106
105
|
- lib/bashly/settings.rb
|
107
106
|
- lib/bashly/templates/bashly.yml
|
108
107
|
- lib/bashly/templates/lib/colors.sh
|
@@ -113,6 +112,7 @@ files:
|
|
113
112
|
- lib/bashly/templates/strings.yml
|
114
113
|
- lib/bashly/version.rb
|
115
114
|
- lib/bashly/views/argument/usage.erb
|
115
|
+
- lib/bashly/views/command/catch_all_filter.erb
|
116
116
|
- lib/bashly/views/command/command_fallback.erb
|
117
117
|
- lib/bashly/views/command/command_filter.erb
|
118
118
|
- lib/bashly/views/command/command_functions.erb
|