dip 3.6.1 → 3.7.0

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: a6ed9787f57436a499d2003b50c9a1775948f74785477e6b8ed2d99ffcc215a8
4
- data.tar.gz: 91de83c0a7347e66ccf7aae58fb48649817b2b654ff4840ff850e298073a096f
3
+ metadata.gz: 5eaf38b3627e299f0f3d6e6650d21ea564a6f38bb1ce84afc8fff76a1665b0d5
4
+ data.tar.gz: af01914d8226fc9c886b266098303fccde34e18e78a1cc3c8225119e1f127c5f
5
5
  SHA512:
6
- metadata.gz: 10f3c53ad59b05e9dcfb887510fd2b76c487546374cdb24a778c1d4e05579b764f2a8cdd915f0dadaf9462aa65f4bc60bb25759dfa497011f9f84f0fb386a60e
7
- data.tar.gz: c1e87222e4a1e235de27e75e242a802ad4f449ffdd0e0bfbdebdd3c118d34f9d1ca50417e0ae7a978df7c485739ac6793932d0dd63efea353ef58ca196e64aa5
6
+ metadata.gz: e18bb5db1b8e11fe071f182016e8e117090b662551388969f68199d3314a730995f6697827ede5449aee4f514302d586a4828bb8b71b152f0dfc95df2757aa37
7
+ data.tar.gz: 1ef69de40baedbf4ae515fff82386eb8058bd79ce7eb36ee1cca7edac07046bd41ca3801910ce32d3c1c5734ef78b05783ca073264b547b1ffdcd66c0681ea51
data/README.md CHANGED
@@ -22,10 +22,10 @@ Command line utility that gives the "native" interaction with applications confi
22
22
 
23
23
  ## Integration with shell
24
24
 
25
- Dip can be injected into current shell. For now, it supported ZSH only.
25
+ Dip can be injected into current shell (ZSH or Bash).
26
26
 
27
27
  ```sh
28
- dip console | source /dev/stdin
28
+ eval "$(dip console)"
29
29
  ```
30
30
 
31
31
  After that we can type commands without `dip` prefix. For example:
@@ -46,6 +46,9 @@ Also, in shell mode Dip is trying to determine passed manually environment varia
46
46
  VERSION=20180515103400 rails db:migrate:down
47
47
  ```
48
48
 
49
+ You could add this `eval` at the end of your `~/.zshrc`, or `~/.bashrc`, or `~/.bash_profile`.
50
+ After that, it will be automatically applied when you open your preferred terminal.
51
+
49
52
  ## Installation
50
53
 
51
54
  ```sh
@@ -50,12 +50,17 @@ module Dip
50
50
  end
51
51
  end
52
52
 
53
- desc "up [OPTIONS] SERVICE", "Run docker-compose up command"
53
+ desc "up [OPTIONS] SERVICE", "Run `docker-compose up` command"
54
54
  def up(*argv)
55
55
  compose("up", *argv)
56
56
  end
57
57
 
58
- desc "down [OPTIONS]", "Run docker-compose down command"
58
+ desc "stop [OPTIONS] SERVICE", "Run `docker-compose stop` command"
59
+ def stop(*argv)
60
+ compose("stop", *argv)
61
+ end
62
+
63
+ desc "down [OPTIONS]", "Run `docker-compose down` command"
59
64
  def down(*argv)
60
65
  compose("down", *argv)
61
66
  end
@@ -97,7 +102,7 @@ module Dip
97
102
  subcommand :nginx, Dip::CLI::Nginx
98
103
 
99
104
  require_relative 'cli/console'
100
- desc "console", "Integrate Dip commands into shell (only ZSH is supported now)"
105
+ desc "console", "Integrate Dip commands into shell (only ZSH and Bash is supported)"
101
106
  subcommand :console, Dip::CLI::Console
102
107
  end
103
108
  end
@@ -18,6 +18,48 @@ module Dip
18
18
  export DIP_EARLY_ENVS=#{ENV.keys.join(',')}
19
19
  export DIP_PROMPT_TEXT="ⅆ"
20
20
 
21
+ function dip_clear() {
22
+ # just stub, will be redefined after injecting aliases
23
+ true
24
+ }
25
+
26
+ function dip_inject() {
27
+ eval "$(#{Dip.bin_path} console inject)"
28
+ }
29
+
30
+ function dip_reload() {
31
+ dip_clear
32
+ dip_inject
33
+ }
34
+
35
+ # Inspired by RVM
36
+ function __zsh_like_cd() {
37
+ \\typeset __zsh_like_cd_hook
38
+ if
39
+ builtin "$@"
40
+ then
41
+ for __zsh_like_cd_hook in chpwd "${chpwd_functions[@]}"
42
+ do
43
+ if \\typeset -f "$__zsh_like_cd_hook" >/dev/null 2>&1
44
+ then "$__zsh_like_cd_hook" || break # finish on first failed hook
45
+ fi
46
+ done
47
+ true
48
+ else
49
+ return $?
50
+ fi
51
+ }
52
+
53
+ [[ -n "${ZSH_VERSION:-}" ]] ||
54
+ {
55
+ function cd() { __zsh_like_cd cd "$@" ; }
56
+ function popd() { __zsh_like_cd popd "$@" ; }
57
+ function pushd() { __zsh_like_cd pushd "$@" ; }
58
+ }
59
+
60
+ export -a chpwd_functions
61
+ [[ " ${chpwd_functions[*]} " == *" dip_reload "* ]] || chpwd_functions+=(dip_reload)
62
+
21
63
  if [[ "$ZSH_THEME" = "agnoster" ]]; then
22
64
  eval "`declare -f prompt_end | sed '1s/.*/_&/'`"
23
65
 
@@ -30,25 +72,14 @@ module Dip
30
72
  }
31
73
  fi
32
74
 
33
- function dip_remove_aliases() {
34
- # will be redefined
35
- }
36
-
37
- function dip_source_aliases() {
38
- #{Dip.bin_path} console inject | source /dev/stdin
39
- }
40
-
41
- dip_source_aliases
42
-
43
- function chpwd() {
44
- dip_remove_aliases
45
- dip_source_aliases
46
- }
75
+ dip_reload
47
76
  SH
48
77
  end
49
78
  end
50
79
 
51
80
  class Inject < Dip::Command
81
+ attr_reader :out, :aliases
82
+
52
83
  def initialize
53
84
  @aliases = []
54
85
  @out = []
@@ -56,38 +87,27 @@ module Dip
56
87
 
57
88
  def execute
58
89
  if Dip::Config.exist?
59
- alias_interaction if Dip.config.interaction
60
- alias_compose
61
- add_alias("provision")
90
+ add_aliases(*Dip.config.interaction.keys) if Dip.config.interaction
91
+ add_aliases("compose", "up", "stop", "down", "provision")
62
92
  end
63
93
 
64
- fill_removing_aliases
94
+ clear_aliases
65
95
 
66
- puts @out.join("\n\n")
96
+ puts out.join("\n\n")
67
97
  end
68
98
 
69
99
  private
70
100
 
71
- def alias_interaction
72
- Dip.config.interaction.keys.each do |name|
73
- add_alias(name)
101
+ def add_aliases(*names)
102
+ names.each do |name|
103
+ aliases << name
104
+ out << "function #{name}() { #{Dip.bin_path} #{name} $@; }"
74
105
  end
75
106
  end
76
107
 
77
- def alias_compose
78
- %w(compose up down).each do |name|
79
- add_alias(name)
80
- end
81
- end
82
-
83
- def add_alias(name)
84
- @aliases << name
85
- @out << "function #{name}() { #{Dip.bin_path} #{name} $@; }"
86
- end
87
-
88
- def fill_removing_aliases
89
- @out << "function dip_remove_aliases() { \n" \
90
- "#{@aliases.map { |a| " unset -f #{a}" }.join("\n")} " \
108
+ def clear_aliases
109
+ out << "function dip_clear() { \n" \
110
+ "#{aliases.any? ? aliases.map { |a| " unset -f #{a}" }.join("\n") : 'true'} " \
91
111
  "\n}"
92
112
  end
93
113
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dip
4
- VERSION = "3.6.1"
4
+ VERSION = "3.7.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dip
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.1
4
+ version: 3.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - bibendi