bashly 1.2.0 → 1.2.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: 5000e81ecf047c31547832097355e0d1b5de630041ef2533a80ce70f146e8282
4
- data.tar.gz: 9c03b8ef9215a317ebfd75333304065c271e77296a55753de65e612f9d1a8432
3
+ metadata.gz: 36c0868dbf2a0e4d5d2fecdc5854aac4e1bea8f7953a07712ccc985289c89b57
4
+ data.tar.gz: 63df3d720e1b36ce7ab658224fde796fb9460c92c7946bd867204c0e0caea304
5
5
  SHA512:
6
- metadata.gz: c6dc6b49075f6e250aec3204f6b9ff2bd6e4236da1bcc5229691565dcc8a4ff4c1d1c06a139c092eae33c61123753cdb542583a69596caf299f87c6ccf3d4f07
7
- data.tar.gz: ab9d9fc13a779bfd4d71adbae49e66961c697a46e5cb386875dac1d9e1b021828a2821332f2687d16b87b3fb820cdc006b61d86e7425dd6fdb37ac7aceb12b33
6
+ metadata.gz: 39e367d86e8bf21ae076c35887157234e7d39d003f17a596aa4711a02a87c6b3856ac27b0f1c73c30837b2589358e479c069dba4cff657431fdca98f44116718
7
+ data.tar.gz: eceaabeafea2e93a9cf7c9d7c2f999a2303c0d9172ddd7799bb0d1f9eafe62166ee9512d8688ad9cc6547dd28e20b7c8925ca489cb2639fd3cd2456517461e7a
@@ -19,7 +19,7 @@ module Bashly
19
19
  terminal = MisterBin::Terminal.new runner, {
20
20
  autocomplete: autocomplete,
21
21
  show_usage: true,
22
- prompt: "\n$> bashly ",
22
+ prompt: "$ bashly ",
23
23
  }
24
24
 
25
25
  terminal.on('help') { runner.run %w[--help] }
@@ -231,6 +231,10 @@ module Bashly
231
231
  assert value['args'].last['repeatable'],
232
232
  "#{key}.args cannot contain a repeatable arg unless it is the last one"
233
233
  end
234
+
235
+ required_order = value['args'].map { |x| x['required'] ? true : false }
236
+ refute required_order.include_sequence?(false, true),
237
+ "#{key}.args cannot contain required arg after optional arg"
234
238
  end
235
239
 
236
240
  if value['expose']
@@ -13,4 +13,10 @@ class Array
13
13
  def nonuniq
14
14
  tally.select { |_key, count| count > 1 }.keys
15
15
  end
16
+
17
+ def include_sequence?(*elements)
18
+ return false if elements.empty?
19
+
20
+ each_cons(elements.size).any?(elements)
21
+ end
16
22
  end
@@ -1,3 +1,3 @@
1
1
  module Bashly
2
- VERSION = '1.2.0'
2
+ VERSION = '1.2.1'
3
3
  end
@@ -3,6 +3,7 @@ if validate
3
3
 
4
4
  if repeatable
5
5
  > if [[ -v args['{{ name }}'] ]]; then
6
+ > values=''
6
7
  > eval "values=(${args['{{ name }}']})"
7
8
  > for value in "${values[@]}"; do
8
9
  > if [[ -n $(validate_{{ validate }} "$value") ]]; then
@@ -4,7 +4,9 @@ if commands.any?
4
4
  > action=${1:-}
5
5
  >
6
6
  > case $action in
7
- > -*) ;;
7
+ unless default_command
8
+ > -*) ;;
9
+ end
8
10
  >
9
11
 
10
12
  commands.each do |command|
@@ -1,7 +1,11 @@
1
1
  = view_marker
2
2
 
3
3
  > normalize_input() {
4
- > local arg flags passthru
4
+ if Settings.compact_short_flags
5
+ > local arg passthru flags
6
+ else
7
+ > local arg passthru
8
+ end
5
9
  > passthru=false
6
10
  >
7
11
  > while [[ $# -gt 0 ]]; do
@@ -3,6 +3,7 @@ if whitelisted_args.any? or whitelisted_flags.any?
3
3
 
4
4
  whitelisted_args.each do |arg|
5
5
  if arg.repeatable
6
+ > input_array=''
6
7
  > eval "input_array=(${args[{{ arg.name }}]})"
7
8
  > for i in "${input_array[@]}"; do
8
9
  > if [[ ! $i =~ ^({{ arg.allowed.join '|' }})$ ]]; then
@@ -22,6 +23,7 @@ if whitelisted_args.any? or whitelisted_flags.any?
22
23
 
23
24
  whitelisted_flags.each do |flag|
24
25
  if flag.repeatable
26
+ > input_array=''
25
27
  > eval "input_array=(${args[{{ flag.name }}]})"
26
28
  > for i in "${input_array[@]}"; do
27
29
  > if [[ ! $i =~ ^({{ flag.allowed.join '|' }})$ ]]; then
@@ -3,6 +3,7 @@ if validate
3
3
 
4
4
  if repeatable
5
5
  > if [[ -v args['{{ long }}'] ]]; then
6
+ > values=''
6
7
  > eval "values=(${args['{{ long }}']})"
7
8
  > for value in "${values[@]}"; do
8
9
  > if [[ -n $(validate_{{ validate }} "$value") ]]; then
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: 1.2.0
4
+ version: 1.2.1
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: 2024-07-05 00:00:00.000000000 Z
11
+ date: 2024-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colsole