envo 0.1.1 → 0.1.3
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 +4 -4
- data/LICENSE +1 -1
- data/README.md +3 -1
- data/bin/envo-install +1 -1
- data/bin/envo_gen_tmp_helper.rb +0 -1
- data/lib/envo/cli/envo.bat +1 -1
- data/lib/envo/cli/{installer_bash.rb → installer_sh_like.rb} +11 -8
- data/lib/envo/host.rb +5 -0
- data/lib/envo/host_shell.rb +2 -0
- data/lib/envo/shell/bash.rb +3 -54
- data/lib/envo/shell/sh_like.rb +57 -0
- data/lib/envo/shell/win_cmd.rb +2 -2
- data/lib/envo/shell/zsh.rb +12 -0
- data/lib/envo/val/list_val.rb +1 -4
- data/lib/envo/val/path_list_val.rb +32 -4
- data/lib/envo/version.rb +1 -1
- data/lib/envo.rb +4 -2
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 230b0d48de4d6bbe0e3b47c43ad57a9e318087b14b2321709a46aeb7a5efdf82
|
4
|
+
data.tar.gz: 39c5e2c9c6d000ec3571bf31d3fb79c788e81ea1700303fb84e365afc599c7da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d00ebac8fbf454a4a1189b6e426f69f84b5e0971f7489f16906076a2eb946439d88eac420f3741686ca97b9a4f9d232ef317d41fe03599223c3851ac860634c
|
7
|
+
data.tar.gz: 9260b54fb17cbf07b38b3df416546180d7095817472d447d53a7a016d88633e69fc7270dbe90694cbc113e3417ea170a532743e98b79974d2ece70d0cbae5a4d
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Envo
|
2
2
|
|
3
|
+
[](https://badge.fury.io/rb/envo)
|
4
|
+
|
3
5
|
A command-line environment variable manager for the current shell session. It works with bash and Windows cmd.
|
4
6
|
|
5
7
|
Envo offers several commands to view and change environment variables and also to execute simple scripts composed of those commands, thus allowing the same script for a particular env-var configuration on all supported platforms.
|
@@ -63,4 +65,4 @@ Please take a look at [the implementation notes](doc/impl-notes.md) and [the roa
|
|
63
65
|
|
64
66
|
This software is distributed under the MIT Software License. See accompanying LICENSE file or copy [here](https://opensource.org/licenses/MIT).
|
65
67
|
|
66
|
-
Copyright © 2020 [Borislav Stanimirov](http://github.com/iboB)
|
68
|
+
Copyright © 2020-2024 [Borislav Stanimirov](http://github.com/iboB)
|
data/bin/envo-install
CHANGED
data/bin/envo_gen_tmp_helper.rb
CHANGED
@@ -13,7 +13,6 @@ fname = "envo-" + Time.now.to_i.to_s(16) + '-' + rand(1_000_000).to_s(16) + ".ba
|
|
13
13
|
# find the os, and use OS-specific ways, but we're trying to be fast here
|
14
14
|
|
15
15
|
def temp_dirs(&block)
|
16
|
-
yield 'C:/windows/system32'
|
17
16
|
yield '/tmp' # most unixes
|
18
17
|
yield ENV['TMP'] # good guess for windows
|
19
18
|
yield '/var/tmp'
|
data/lib/envo/cli/envo.bat
CHANGED
@@ -2,12 +2,16 @@
|
|
2
2
|
|
3
3
|
module Envo
|
4
4
|
module Cli
|
5
|
-
class
|
5
|
+
class InstallerShLike
|
6
6
|
# def detect_installed_envo?()
|
7
7
|
# stdout, stderr, code = Open3.capture3("bash -ic 'command -v envo'")
|
8
8
|
# code.success?
|
9
9
|
# end
|
10
10
|
|
11
|
+
def initialize(default_dotfile)
|
12
|
+
@default_dotfile = File.join(Dir.home, default_dotfile)
|
13
|
+
end
|
14
|
+
|
11
15
|
ENVO_INSTALLATION_BEGIN = '### BEGIN envo installation (don\'t remove line)'
|
12
16
|
ENVO_INSTALLATION_END = '### END envo installation (don\'t remove line)'
|
13
17
|
|
@@ -32,7 +36,7 @@ module Envo
|
|
32
36
|
|
33
37
|
if !first || !last
|
34
38
|
raise Envo::Error.new <<~EOF
|
35
|
-
#{dotfile}' contains a broken
|
39
|
+
#{dotfile}' contains a broken envo insallation.
|
36
40
|
You need to remove it manually
|
37
41
|
EOF
|
38
42
|
end
|
@@ -62,8 +66,8 @@ module Envo
|
|
62
66
|
|
63
67
|
File.open(dotfile, openmode) { |f| f.puts install_lines }
|
64
68
|
puts <<~EOF
|
65
|
-
Sucessfully installed
|
66
|
-
Source the file, or restart the
|
69
|
+
Sucessfully installed envo to '#{dotfile}'
|
70
|
+
Source the file, or restart the shell session if the file is auto-sourced.
|
67
71
|
EOF
|
68
72
|
end
|
69
73
|
|
@@ -76,16 +80,15 @@ module Envo
|
|
76
80
|
lines = found[:lines]
|
77
81
|
lines[found[:first], found[:num]] = []
|
78
82
|
File.open(dotfile, 'w') { |f| f.puts lines }
|
79
|
-
puts "Suncessfully uninstalled
|
83
|
+
puts "Suncessfully uninstalled envo from '#{dotfile}'"
|
80
84
|
end
|
81
85
|
|
82
|
-
DEFAULT_DOTFILE = File.join(Dir.home, '.bashrc')
|
83
86
|
USAGE = <<~EOF
|
84
87
|
usage: envo-install [u] [--dotfile <path>]
|
85
88
|
EOF
|
86
89
|
def run(argv)
|
87
90
|
if argv.empty?
|
88
|
-
try_install(
|
91
|
+
try_install(@default_dotfile)
|
89
92
|
return 0
|
90
93
|
end
|
91
94
|
|
@@ -103,7 +106,7 @@ module Envo
|
|
103
106
|
argv.shift
|
104
107
|
end
|
105
108
|
|
106
|
-
dotfile =
|
109
|
+
dotfile = @default_dotfile
|
107
110
|
if !argv.empty?
|
108
111
|
arg = argv.shift
|
109
112
|
if arg != '--dotfile'
|
data/lib/envo/host.rb
CHANGED
data/lib/envo/host_shell.rb
CHANGED
@@ -5,6 +5,8 @@ module Envo
|
|
5
5
|
if env_shell =~ /bash/
|
6
6
|
raise Error.new "bash on Windows (msys) is not supported yet" if env_shell =~ /^[a-zA-Z]\:/
|
7
7
|
break Shell::Bash
|
8
|
+
elsif env_shell =~ /zsh/
|
9
|
+
break Shell::Zsh
|
8
10
|
end
|
9
11
|
raise Error.new "Unknown shell! Please report on https://github.com/iboB/envo/issues"
|
10
12
|
}.()
|
data/lib/envo/shell/bash.rb
CHANGED
@@ -1,62 +1,11 @@
|
|
1
1
|
module Envo
|
2
2
|
module Shell
|
3
3
|
module Bash
|
4
|
+
extend ShLike
|
4
5
|
extend self
|
5
6
|
|
6
|
-
def
|
7
|
-
Cli::
|
8
|
-
end
|
9
|
-
|
10
|
-
def path_var_name
|
11
|
-
'PATH'
|
12
|
-
end
|
13
|
-
def home_var_name
|
14
|
-
'HOME'
|
15
|
-
end
|
16
|
-
|
17
|
-
def likely_abs_path?(val)
|
18
|
-
!val.empty? && val[0] == '/'
|
19
|
-
end
|
20
|
-
def likely_rel_path?(val)
|
21
|
-
return !val.empty? && val[0] == '.'
|
22
|
-
end
|
23
|
-
def fix_path(path)
|
24
|
-
path
|
25
|
-
end
|
26
|
-
|
27
|
-
LIST_SEP = ':'
|
28
|
-
def likely_list?(val)
|
29
|
-
# we have some work
|
30
|
-
# if the value includes our list separtor ":", we need to make sure whether a url:port combination is not a better fit
|
31
|
-
return false if !val.include?(LIST_SEP)
|
32
|
-
|
33
|
-
sep_cnt = val.count(LIST_SEP)
|
34
|
-
return true if sep_cnt > 2
|
35
|
-
|
36
|
-
# match scheme://url
|
37
|
-
return false if val =~ /^\w+\:\/\//
|
38
|
-
|
39
|
-
return true if sep_cnt == 2 # everything else with 2 separators is a list
|
40
|
-
|
41
|
-
# match display type strings address:digit.digit
|
42
|
-
return false if val =~ /\:\d.\d$/
|
43
|
-
|
44
|
-
# match something:number to be interpreted as addr:port
|
45
|
-
!(val =~ /.*\:\d+$/)
|
46
|
-
end
|
47
|
-
def list_to_ar(list)
|
48
|
-
list.split(LIST_SEP)
|
49
|
-
end
|
50
|
-
def ar_to_list(ar)
|
51
|
-
ar.join(LIST_SEP)
|
52
|
-
end
|
53
|
-
|
54
|
-
def cmd_set_env_var(name, value)
|
55
|
-
escaped = value.to_s.inspect.gsub("'"){ "\\'" }
|
56
|
-
"export #{name}=#{escaped}"
|
57
|
-
end
|
58
|
-
def cmd_unset_env_var(name)
|
59
|
-
"unset -v #{name}"
|
7
|
+
def make_installer
|
8
|
+
Cli::InstallerShLike.new '.bashrc'
|
60
9
|
end
|
61
10
|
end
|
62
11
|
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Envo
|
2
|
+
module Shell
|
3
|
+
module ShLike
|
4
|
+
def path_var_name
|
5
|
+
'PATH'
|
6
|
+
end
|
7
|
+
def home_var_name
|
8
|
+
'HOME'
|
9
|
+
end
|
10
|
+
|
11
|
+
def likely_abs_path?(val)
|
12
|
+
!val.empty? && val[0] == '/'
|
13
|
+
end
|
14
|
+
def likely_rel_path?(val)
|
15
|
+
return !val.empty? && val[0] == '.'
|
16
|
+
end
|
17
|
+
def fix_path(path)
|
18
|
+
path
|
19
|
+
end
|
20
|
+
|
21
|
+
LIST_SEP = ':'
|
22
|
+
def likely_list?(val)
|
23
|
+
# we have some work
|
24
|
+
# if the value includes our list separtor ":", we need to make sure whether a url:port combination is not a better fit
|
25
|
+
return false if !val.include?(LIST_SEP)
|
26
|
+
|
27
|
+
sep_cnt = val.count(LIST_SEP)
|
28
|
+
return true if sep_cnt > 2
|
29
|
+
|
30
|
+
# match scheme://url
|
31
|
+
return false if val =~ /^\w+\:\/\//
|
32
|
+
|
33
|
+
return true if sep_cnt == 2 # everything else with 2 separators is a list
|
34
|
+
|
35
|
+
# match display type strings address:digit.digit
|
36
|
+
return false if val =~ /\:\d.\d$/
|
37
|
+
|
38
|
+
# match something:number to be interpreted as addr:port
|
39
|
+
!(val =~ /.*\:\d+$/)
|
40
|
+
end
|
41
|
+
def list_to_ar(list)
|
42
|
+
list.split(LIST_SEP)
|
43
|
+
end
|
44
|
+
def ar_to_list(ar)
|
45
|
+
ar.join(LIST_SEP)
|
46
|
+
end
|
47
|
+
|
48
|
+
def cmd_set_env_var(name, value)
|
49
|
+
escaped = value.to_s.inspect.gsub("'"){ "\\'" }
|
50
|
+
"export #{name}=#{escaped}"
|
51
|
+
end
|
52
|
+
def cmd_unset_env_var(name)
|
53
|
+
"unset -v #{name}"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
data/lib/envo/shell/win_cmd.rb
CHANGED
data/lib/envo/val/list_val.rb
CHANGED
@@ -67,13 +67,10 @@ module Envo
|
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
-
def pp_attribs(elem)
|
71
|
-
@ar.count(elem) > 1 ? 'D' : ' '
|
72
|
-
end
|
73
70
|
def pretty_print(ctx)
|
74
71
|
ctx.puts "["
|
75
72
|
@ar.each_with_index do |v, i|
|
76
|
-
str =
|
73
|
+
str = @ar.count(v) > 1 ? 'D ' : ' '
|
77
74
|
str += "#{i}:".ljust(4)
|
78
75
|
str += v
|
79
76
|
ctx.puts str
|
@@ -13,12 +13,40 @@ module Envo
|
|
13
13
|
def accept_item?(item)
|
14
14
|
item.type == :path
|
15
15
|
end
|
16
|
-
|
17
|
-
|
16
|
+
|
17
|
+
def make_helper_map
|
18
|
+
@ar.map { |p|
|
19
|
+
id = @host.path_id(p)
|
20
|
+
{ str: p, id: id }
|
21
|
+
}
|
18
22
|
end
|
23
|
+
|
24
|
+
def pretty_print(ctx)
|
25
|
+
helper = make_helper_map
|
26
|
+
|
27
|
+
ctx.puts "["
|
28
|
+
helper.each_with_index do |v, i|
|
29
|
+
dupes = helper.count { |e|
|
30
|
+
if e[:str] == v[:str] then true
|
31
|
+
elsif e[:id] == -1 then false
|
32
|
+
else e[:id] == v[:id]
|
33
|
+
end
|
34
|
+
}
|
35
|
+
str = dupes > 1 ? 'D' : ' '
|
36
|
+
str += v[:id] != -1 ? ' ' : 'N'
|
37
|
+
str += ' '
|
38
|
+
str += "#{i}:".ljust(4)
|
39
|
+
str += v[:str]
|
40
|
+
ctx.puts str
|
41
|
+
end
|
42
|
+
ctx.puts ']'
|
43
|
+
end
|
44
|
+
|
19
45
|
def clean!
|
20
|
-
|
21
|
-
|
46
|
+
helper = make_helper_map
|
47
|
+
helper.select! { |e| e[:id] != -1 }
|
48
|
+
helper.uniq! { |e| e[:id] }
|
49
|
+
@ar = helper.map { |e| e[:str] }
|
22
50
|
end
|
23
51
|
end
|
24
52
|
end
|
data/lib/envo/version.rb
CHANGED
data/lib/envo.rb
CHANGED
@@ -32,7 +32,9 @@ module Envo
|
|
32
32
|
autoload :Logger, "envo/logger"
|
33
33
|
|
34
34
|
module Shell
|
35
|
-
autoload :
|
35
|
+
autoload :ShLike, 'envo/shell/sh_like'
|
36
|
+
autoload :Bash, 'envo/shell/bash'
|
37
|
+
autoload :Zsh, 'envo/shell/zsh'
|
36
38
|
autoload :WinCmd, 'envo/shell/win_cmd'
|
37
39
|
end
|
38
40
|
|
@@ -40,6 +42,6 @@ module Envo
|
|
40
42
|
autoload :Runner, 'envo/cli/runner'
|
41
43
|
autoload :Help, 'envo/cli/help'
|
42
44
|
autoload :InstallerWinCmd, 'envo/cli/installer_win_cmd'
|
43
|
-
autoload :
|
45
|
+
autoload :InstallerShLike, 'envo/cli/installer_sh_like'
|
44
46
|
end
|
45
47
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: envo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Borislav Stanimirov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |
|
14
14
|
A CLI environment variable manager.
|
@@ -29,7 +29,7 @@ files:
|
|
29
29
|
- lib/envo/cli/envo.bat
|
30
30
|
- lib/envo/cli/envo.sh
|
31
31
|
- lib/envo/cli/help.rb
|
32
|
-
- lib/envo/cli/
|
32
|
+
- lib/envo/cli/installer_sh_like.rb
|
33
33
|
- lib/envo/cli/installer_win_cmd.rb
|
34
34
|
- lib/envo/cli/runner.rb
|
35
35
|
- lib/envo/cli_parser.rb
|
@@ -54,7 +54,9 @@ files:
|
|
54
54
|
- lib/envo/parsed_cmd.rb
|
55
55
|
- lib/envo/script_parser.rb
|
56
56
|
- lib/envo/shell/bash.rb
|
57
|
+
- lib/envo/shell/sh_like.rb
|
57
58
|
- lib/envo/shell/win_cmd.rb
|
59
|
+
- lib/envo/shell/zsh.rb
|
58
60
|
- lib/envo/state.rb
|
59
61
|
- lib/envo/val/list_val.rb
|
60
62
|
- lib/envo/val/no_val.rb
|
@@ -68,7 +70,7 @@ licenses:
|
|
68
70
|
- MIT
|
69
71
|
metadata: {}
|
70
72
|
post_install_message: |
|
71
|
-
Thanks for installing envo v0.1.
|
73
|
+
Thanks for installing envo v0.1.3 alpha!
|
72
74
|
For the tool to work you must also run the installation program:
|
73
75
|
$ envo-install
|
74
76
|
Running it will complete the setup and 'envo' should be available as a command.
|
@@ -88,8 +90,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
90
|
- !ruby/object:Gem::Version
|
89
91
|
version: '0'
|
90
92
|
requirements: []
|
91
|
-
rubygems_version: 3.
|
93
|
+
rubygems_version: 3.3.25
|
92
94
|
signing_key:
|
93
95
|
specification_version: 4
|
94
|
-
summary:
|
96
|
+
summary: A CLI environment variable manager
|
95
97
|
test_files: []
|