bashly 0.6.7 → 0.6.8

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: c47271e43a775ff08c071428540301ed1fa0656c7d58020c9825dfbc492804ef
4
- data.tar.gz: fdc8ac40f1d18c2bc90ae4700fd0757e55132852bbdf8700a2829a02dd3be61c
3
+ metadata.gz: 6f0b22d0ac9bf41f91fed37e60996fa5175346a9e2e5e56158b760ededfef2a0
4
+ data.tar.gz: 39ffcd5e199b6b79fd04a4bd38e93d4703ad7aebce0ec4970b8250280112c5db
5
5
  SHA512:
6
- metadata.gz: aff1e0723cdfdc10c409697cb2c715a37382dc7dbef3da3afe3b0e45fc8c91255ffeda153d24a25aa3bdcdf67ff863cfa7bec4558f79fced3d3ff33dc720b4d1
7
- data.tar.gz: 54aa504a25003ddf1331e39de9b68612d2fff39bedc93dfc09bc961254c6b4ba7beacadf90412af6d76f9159bffb48456b6d6e85e5c805864372221f2edfbe2e
6
+ metadata.gz: fd57501ae8a6fc8b3072320dc7358b2097ef9b280b5e8b80efa52155c91a9fe56abbb73821ffc2b8a8a8e55caf7a61dd46ef29d8c88f49b2232cddfccff77a32
7
+ data.tar.gz: 83f7293f9b543d6330daedf6421678b3c321166751708dba0985d7aa18a9191510a3832bd2ac8d2a3510b09f9eb2064403798b38894c7227a63f8c86f52f04dc
@@ -3,11 +3,12 @@ module Bashly
3
3
  class Generate < Base
4
4
  help "Generate the bash script and required files"
5
5
 
6
- usage "bashly generate [--force --wrap FUNCTION]"
6
+ usage "bashly generate [--force --quiet --wrap FUNCTION]"
7
7
  usage "bashly generate (-h|--help)"
8
8
 
9
9
  option "-f --force", "Overwrite existing files"
10
10
  option "-w --wrap FUNCTION", "Wrap the entire script in a function so it can also be sourced"
11
+ option "-q --quiet", "Disable on-screen progress report"
11
12
 
12
13
  environment "BASHLY_SOURCE_DIR", "The path containing the bashly configuration and source files [default: src]"
13
14
  environment "BASHLY_TARGET_DIR", "The path to use for creating the bash script [default: .]"
@@ -18,13 +19,17 @@ module Bashly
18
19
  def run
19
20
  create_user_files
20
21
  create_master_script
21
- say "run !txtpur!#{master_script_path} --help!txtrst! to test your bash script"
22
+ quiet_say "run !txtpur!#{master_script_path} --help!txtrst! to test your bash script"
22
23
  end
23
24
 
24
25
  private
25
26
 
27
+ def quiet_say(message)
28
+ say message unless args['--quiet']
29
+ end
30
+
26
31
  def create_user_files
27
- say "creating user files in !txtgrn!#{Settings.source_dir}"
32
+ quiet_say "creating user files in !txtgrn!#{Settings.source_dir}"
28
33
 
29
34
  create_file "#{Settings.source_dir}/initialize.sh", command.render(:default_initialize_script)
30
35
 
@@ -50,17 +55,17 @@ module Bashly
50
55
 
51
56
  def create_file(file, content)
52
57
  if File.exist? file and !args['--force']
53
- say "skipped !txtgrn!#{file}!txtrst! (exists)"
58
+ quiet_say "skipped !txtgrn!#{file}!txtrst! (exists)"
54
59
  else
55
60
  File.write file, content
56
- say "created !txtgrn!#{file}"
61
+ quiet_say "created !txtgrn!#{file}"
57
62
  end
58
63
  end
59
64
 
60
65
  def create_master_script
61
66
  File.write master_script_path, script.code
62
67
  FileUtils.chmod "+x", master_script_path
63
- say "created !txtgrn!#{master_script_path}"
68
+ quiet_say "created !txtgrn!#{master_script_path}"
64
69
  end
65
70
 
66
71
  def script
@@ -24,7 +24,7 @@ class String
24
24
  end
25
25
 
26
26
  def lint
27
- gsub(/\n{2,}/, "\n\n")
27
+ gsub(/\s+\n/m, "\n\n")
28
28
  end
29
29
 
30
30
  end
@@ -22,12 +22,30 @@ module Bashly
22
22
  private
23
23
 
24
24
  def header
25
- @header ||= render('header')
25
+ @header ||= header!
26
+ end
27
+
28
+ def header!
29
+ if File.exist? custom_header_path
30
+ File.read custom_header_path
31
+ else
32
+ default_header
33
+ end
34
+ end
35
+
36
+ def default_header
37
+ result = render('header')
38
+ result += render('bash3_bouncer') unless function_name
39
+ result
26
40
  end
27
41
 
28
42
  def body
29
43
  @body ||= command.render('master_script')
30
44
  end
45
+
46
+ def custom_header_path
47
+ @custom_header_path ||= "#{Settings.source_dir}/header.sh"
48
+ end
31
49
  end
32
50
  end
33
51
  end
@@ -1,3 +1,3 @@
1
1
  module Bashly
2
- VERSION = "0.6.7"
2
+ VERSION = "0.6.8"
3
3
  end
@@ -4,10 +4,5 @@ initialize() {
4
4
  long_usage=''
5
5
  set -e
6
6
 
7
- if [[ "${BASH_VERSINFO:-0}" -lt 4 ]]; then
8
- printf "<%= strings[:unsupported_bash_version] -%>\n"
9
- exit 1
10
- fi
11
-
12
7
  <%= load_user_file("initialize.sh", placeholder: false).indent 2 %>
13
8
  }
@@ -0,0 +1,5 @@
1
+ # :script.bash3_bouncer
2
+ if [[ "${BASH_VERSINFO:-0}" -lt 4 ]]; then
3
+ printf "<%= strings[:unsupported_bash_version] -%>\n"
4
+ exit 1
5
+ fi
@@ -1,3 +1,4 @@
1
1
  #!/usr/bin/env bash
2
2
  # This script was generated by bashly (https://github.com/DannyBen/bashly)
3
3
  # Modifying it manually is not recommended
4
+
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.7
4
+ version: 0.6.8
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-09-27 00:00:00.000000000 Z
11
+ date: 2021-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colsole
@@ -143,6 +143,7 @@ files:
143
143
  - lib/bashly/views/environment_variable/usage.erb
144
144
  - lib/bashly/views/flag/case.erb
145
145
  - lib/bashly/views/flag/usage.erb
146
+ - lib/bashly/views/script/bash3_bouncer.erb
146
147
  - lib/bashly/views/script/header.erb
147
148
  - lib/bashly/views/script/wrapper.erb
148
149
  homepage: https://github.com/dannyben/bashly