bashly 0.4.1rc1 → 0.4.1

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: e31810f90eb5199f74dd9fd0dc0aedfb4bfd5dd4f38bc4e36473ab6c3e4f10d2
4
- data.tar.gz: 5de458e2eea4ec796e44a67cddeabaf848ef069ec2d37ad7ddb1f3cc660bad27
3
+ metadata.gz: 7e2d8e44019822a048ede2fadd9da870df078afad2931470748912b25acfb93f
4
+ data.tar.gz: 84738b8835be3af778b0df351154c2a73c966ee906317f61534c8100a17da9f8
5
5
  SHA512:
6
- metadata.gz: 72a03554e17b648efda96ac0208bd4ee8223680717933a71907994ca3a3db3ffd629ea3572fc27143babb6634a65ad2f0b83fdeaeea2ab01d0c4755ea630f674
7
- data.tar.gz: eb955f344c428e92b82150b95256f3c9d90e3461353bb6b13cad68eeb17bf5e6220991590aa1d797b447ee5c92f414ef9b5042b13569a284595dac0cadd7babd
6
+ metadata.gz: 653e9a5a685d321837472cb2522f93aeabc0ed0de479f97ca35dcbb1d08e2bd997d50e17653c464ce201388f6b21ac59fa4b9d28a01beed5d5119beb8b278e1b
7
+ data.tar.gz: 79c111478814fb30246a214511946331c7a581196187c41ef6bc249be3858123786bba3596484b27d493288714fb9d257fc18e7b4432b0f77effe8ed7baa740b
@@ -3,14 +3,18 @@ module Bashly
3
3
  class Generate < Base
4
4
  help "Generate the bash script and required files"
5
5
 
6
- usage "bashly generate [--force]"
6
+ usage "bashly generate [--force --wrap FUNCTION]"
7
7
  usage "bashly generate (-h|--help)"
8
8
 
9
9
  option "-f --force", "Overwrite existing files"
10
+ option "-w --wrap FUNCTION", "Wrap the entire script in a function so it can also be sourced"
10
11
 
11
12
  environment "BASHLY_SOURCE_DIR", "The path containing the bashly configuration and source files [default: src]"
12
13
  environment "BASHLY_TARGET_DIR", "The path to use for creating the bash script [default: .]"
13
14
 
15
+ example "bashly generate --force"
16
+ example "bashly generate --wrap my_function"
17
+
14
18
  def run
15
19
  create_user_files
16
20
  create_master_script
@@ -54,12 +58,15 @@ module Bashly
54
58
  end
55
59
 
56
60
  def create_master_script
57
- master_script = command.render('master_script').lint
58
- File.write master_script_path, master_script
61
+ File.write master_script_path, script.code
59
62
  FileUtils.chmod "+x", master_script_path
60
63
  say "created !txtgrn!#{master_script_path}"
61
64
  end
62
65
 
66
+ def script
67
+ @script ||= Models::Script.new(command, args['--wrap'])
68
+ end
69
+
63
70
  def master_script_path
64
71
  "#{Settings.target_dir}/#{command.name}"
65
72
  end
@@ -11,7 +11,8 @@ module Bashly
11
11
  def run
12
12
  config = Config.new "#{Settings.source_dir}/bashly.yml"
13
13
  command = Models::Command.new(config)
14
- puts command.render 'master_script'
14
+ script = Models::Script.new command
15
+ puts script.code
15
16
  end
16
17
  end
17
18
  end
@@ -0,0 +1,33 @@
1
+ module Bashly
2
+ module Models
3
+ class Script
4
+ include Renderable
5
+
6
+ attr_reader :command, :function_name
7
+
8
+ def initialize(command, function_name = nil)
9
+ @command, @function_name = command, function_name
10
+ end
11
+
12
+ def code
13
+ if function_name
14
+ result = [header, render('wrapper')].join "\n"
15
+ else
16
+ result = [header, body].join "\n"
17
+ end
18
+
19
+ result.lint
20
+ end
21
+
22
+ private
23
+
24
+ def header
25
+ @header ||= render('header')
26
+ end
27
+
28
+ def body
29
+ @body ||= command.render('master_script')
30
+ end
31
+ end
32
+ end
33
+ end
@@ -1,3 +1,3 @@
1
1
  module Bashly
2
- VERSION = "0.4.1rc1"
2
+ VERSION = "0.4.1"
3
3
  end
@@ -1,7 +1,3 @@
1
- #!/usr/bin/env bash
2
- # This script was generated by bashly (https://github.com/DannyBen/bashly)
3
- # Modifying it manually is not recommended
4
-
5
1
  <%= render :root_command if commands.empty? %>
6
2
  <%= render :version_command %>
7
3
  <%= render :usage %>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env bash
2
+ # This script was generated by bashly (https://github.com/DannyBen/bashly)
3
+ # Modifying it manually is not recommended
@@ -0,0 +1,6 @@
1
+ # :script.wrapper
2
+ <%= function_name %>() {
3
+ <%= body.indent 2 %>
4
+ }
5
+
6
+ (return 0 2>/dev/null) || <%= function_name %> "$@"
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.4.1rc1
4
+ version: 0.4.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: 2021-02-18 00:00:00.000000000 Z
11
+ date: 2021-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colsole
@@ -80,6 +80,7 @@ files:
80
80
  - lib/bashly/models/command.rb
81
81
  - lib/bashly/models/environment_variable.rb
82
82
  - lib/bashly/models/flag.rb
83
+ - lib/bashly/models/script.rb
83
84
  - lib/bashly/polyfills/hash.rb
84
85
  - lib/bashly/settings.rb
85
86
  - lib/bashly/templates/bashly.yml
@@ -123,6 +124,8 @@ files:
123
124
  - lib/bashly/views/environment_variable/usage.erb
124
125
  - lib/bashly/views/flag/case.erb
125
126
  - lib/bashly/views/flag/usage.erb
127
+ - lib/bashly/views/script/header.erb
128
+ - lib/bashly/views/script/wrapper.erb
126
129
  homepage: https://github.com/dannyben/bashly
127
130
  licenses:
128
131
  - MIT
@@ -138,9 +141,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
138
141
  version: 2.3.0
139
142
  required_rubygems_version: !ruby/object:Gem::Requirement
140
143
  requirements:
141
- - - ">"
144
+ - - ">="
142
145
  - !ruby/object:Gem::Version
143
- version: 1.3.1
146
+ version: '0'
144
147
  requirements: []
145
148
  rubygems_version: 3.2.3
146
149
  signing_key: