bashly 1.2.12 → 1.2.13

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 409606d6cd016389acf10a1d9a44211659b2d567bfd72d62aec4151d4d08846b
4
- data.tar.gz: 3bbefdeee9dff2b530366cbb453fa45390d87f0f45d57fdfd643361fb7a498d2
3
+ metadata.gz: b7352576231f786aa54762d8ae255d5599da89b8a5c1eb98d39bee4f8826cf40
4
+ data.tar.gz: 847a535d109089a3296b4dfce8477f1c3d40cd62183a4aeb662e396efe9a5f95
5
5
  SHA512:
6
- metadata.gz: 0aa662d5e9e82b795f0885337fb033762317fb6a6b4967892ebe777b5adf9e8ec771ae6969f020d26b3a36f33be686ba3a61482cdbd225a8777412a393895c66
7
- data.tar.gz: 6673f3a65b9bf0e4f9aadfc766b3bc2dfff36a21ce1fbabfdd495a0548663237d369561dd2dfccea507e705cdcb70c9654b4f79819e461df467ca8ead950ae43
6
+ metadata.gz: 3b2c74316bd4d9d37a22e58ed20c4986a7ca86e7b74b7222e8f7adcad966f83b29d39b915ca7607f1d3655ef1653390aadcdcea173b9c9818ba475f861d8bbba
7
+ data.tar.gz: 89517c698abb34ec83e04590cd4919f59492fc0b999b3baade304dfde859c7aca231db77a9d469df0fcb7d98634913cb6d2321b6a791732f06c2cf608d962cc8
@@ -102,6 +102,19 @@ settings:
102
102
  - source: "settings/settings.yml"
103
103
  target: "settings.yml"
104
104
 
105
+ stacktrace:
106
+ help: Add a function that shows stacktrace on error.
107
+ files:
108
+ - source: "stacktrace/stacktrace.sh"
109
+ target: "%{user_lib_dir}/stacktrace.%{user_ext}"
110
+ post_install_message: |
111
+ The stacktrace function is designed to be called automatically on error.
112
+
113
+ To enable this functionality, call g`enable_stacktrace` in your
114
+ g`src/initialize.sh`. You may run the following command to add this file:
115
+
116
+ m`$ bashly add hooks`
117
+
105
118
  strings:
106
119
  help: Copy an additional configuration file to your project, allowing you to customize all the tips and error strings.
107
120
  files:
@@ -0,0 +1,29 @@
1
+ ## Stack trace functions [@bashly-upgrade stacktrace]
2
+ ## This file is a part of Bashly standard library
3
+ ##
4
+ ## Usage:
5
+ ## This function is designed to be called on error.
6
+ ##
7
+ ## To enable this functionality, call `enable_stacktrace` in your
8
+ ## `src/initialize.sh` (Run `bashly add hooks` to add this file).
9
+ ##
10
+ enable_stacktrace() {
11
+ trap 'stacktrace' ERR
12
+ set -o errtrace
13
+ set -o errexit
14
+ }
15
+
16
+ stacktrace() {
17
+ local exit_status="$?"
18
+ local i=0
19
+ local caller_output line func file
20
+
21
+ printf "%s:%s in \`%s\`: %s\n" "${BASH_SOURCE[0]}" "${BASH_LINENO[0]}" "${FUNCNAME[1]}" "$BASH_COMMAND"
22
+ printf "\nStack trace:\n"
23
+ while caller_output="$(caller $i)"; do
24
+ read -r line func file <<<"$caller_output"
25
+ printf "\tfrom %s:%s in \`%s\`\n" "$file" "$line" "$func"
26
+ i=$((i + 1))
27
+ done
28
+ exit "$exit_status"
29
+ } >&2
@@ -1,4 +1,6 @@
1
1
  ## [@bashly-upgrade validations]
2
2
  validate_dir_exists() {
3
- [[ -d "$1" ]] || echo "must be an existing directory"
3
+ if [[ ! -d "$1" ]]; then
4
+ echo "must be an existing directory"
5
+ fi
4
6
  }
@@ -1,4 +1,6 @@
1
1
  ## [@bashly-upgrade validations]
2
2
  validate_file_exists() {
3
- [[ -f "$1" ]] || echo "must be an existing file"
3
+ if [[ ! -f "$1" ]]; then
4
+ echo "must be an existing file"
5
+ fi
4
6
  }
@@ -1,4 +1,6 @@
1
1
  ## [@bashly-upgrade validations]
2
2
  validate_integer() {
3
- [[ "$1" =~ ^[0-9]+$ ]] || echo "must be an integer"
4
- }
3
+ if ! [[ "$1" =~ ^[0-9]+$ ]]; then
4
+ echo "must be an integer"
5
+ fi
6
+ }
@@ -1,4 +1,6 @@
1
1
  ## [@bashly-upgrade validations]
2
2
  validate_not_empty() {
3
- [[ -z "$1" ]] && echo "must not be empty"
3
+ if [[ -z "$1" ]]; then
4
+ echo "must not be empty"
5
+ fi
4
6
  }
@@ -87,8 +87,8 @@ module Bashly
87
87
  # flag with arg that is defined as unique
88
88
  def has_unique_args_or_flags?
89
89
  deep_commands(include_self: true).each do |command|
90
- return true if command.args.count(&:unique).positive? ||
91
- command.flags.count(&:unique).positive?
90
+ return true if command.args.any?(&:unique) ||
91
+ command.flags.any?(&:unique)
92
92
  end
93
93
  false
94
94
  end
@@ -1,3 +1,3 @@
1
1
  module Bashly
2
- VERSION = '1.2.12'
2
+ VERSION = '1.2.13'
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bashly
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.12
4
+ version: 1.2.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny Ben Shitrit
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-05-02 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: colsole
@@ -226,6 +226,7 @@ files:
226
226
  - lib/bashly/libraries/render/markdown/render.rb
227
227
  - lib/bashly/libraries/render/markdown/summary.txt
228
228
  - lib/bashly/libraries/settings/settings.yml
229
+ - lib/bashly/libraries/stacktrace/stacktrace.sh
229
230
  - lib/bashly/libraries/strings/strings.yml
230
231
  - lib/bashly/libraries/test/approvals.bash
231
232
  - lib/bashly/libraries/test/approve
@@ -350,7 +351,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
350
351
  - !ruby/object:Gem::Version
351
352
  version: '0'
352
353
  requirements: []
353
- rubygems_version: 3.6.3
354
+ rubygems_version: 3.6.9
354
355
  specification_version: 4
355
356
  summary: Bash Command Line Tool Generator
356
357
  test_files: []