envo 0.1.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 +7 -0
- data/bin/envo-install +18 -0
- data/bin/envo_gen_tmp_helper.rb +50 -0
- data/bin/envo_run +30 -0
- data/lib/envo.rb +45 -0
- data/lib/envo/cli/envo.bat +11 -0
- data/lib/envo/cli/envo.sh +6 -0
- data/lib/envo/cli/help.rb +20 -0
- data/lib/envo/cli/installer_bash.rb +131 -0
- data/lib/envo/cli/installer_win_cmd.rb +96 -0
- data/lib/envo/cli/runner.rb +129 -0
- data/lib/envo/cli_parser.rb +54 -0
- data/lib/envo/cmd_clean.rb +53 -0
- data/lib/envo/cmd_copy.rb +56 -0
- data/lib/envo/cmd_list.rb +50 -0
- data/lib/envo/cmd_list_add.rb +102 -0
- data/lib/envo/cmd_list_del.rb +78 -0
- data/lib/envo/cmd_path.rb +28 -0
- data/lib/envo/cmd_reset.rb +66 -0
- data/lib/envo/cmd_run.rb +68 -0
- data/lib/envo/cmd_set.rb +76 -0
- data/lib/envo/cmd_show.rb +82 -0
- data/lib/envo/cmd_swap.rb +49 -0
- data/lib/envo/cmd_unset.rb +45 -0
- data/lib/envo/context.rb +156 -0
- data/lib/envo/error.rb +7 -0
- data/lib/envo/host.rb +24 -0
- data/lib/envo/host_shell.rb +11 -0
- data/lib/envo/logger.rb +27 -0
- data/lib/envo/parse_result.rb +9 -0
- data/lib/envo/parsed_cmd.rb +10 -0
- data/lib/envo/script_parser.rb +58 -0
- data/lib/envo/shell/bash.rb +63 -0
- data/lib/envo/shell/win_cmd.rb +47 -0
- data/lib/envo/state.rb +71 -0
- data/lib/envo/val/list_val.rb +107 -0
- data/lib/envo/val/no_val.rb +35 -0
- data/lib/envo/val/path_list_val.rb +24 -0
- data/lib/envo/val/path_val.rb +41 -0
- data/lib/envo/val/string_val.rb +40 -0
- data/lib/envo/val/val_builder.rb +59 -0
- data/lib/envo/version.rb +4 -0
- metadata +89 -0
@@ -0,0 +1,35 @@
|
|
1
|
+
module Envo
|
2
|
+
class NoVal
|
3
|
+
def value
|
4
|
+
nil
|
5
|
+
end
|
6
|
+
|
7
|
+
# casts
|
8
|
+
def type
|
9
|
+
:empty
|
10
|
+
end
|
11
|
+
def accept_assign?(other)
|
12
|
+
true
|
13
|
+
end
|
14
|
+
def invalid_description
|
15
|
+
nil
|
16
|
+
end
|
17
|
+
def list?
|
18
|
+
false
|
19
|
+
end
|
20
|
+
def to_list
|
21
|
+
return ListVal.new([])
|
22
|
+
end
|
23
|
+
def to_s
|
24
|
+
''
|
25
|
+
end
|
26
|
+
def pretty_print(ctx)
|
27
|
+
ctx.puts '<empty>'
|
28
|
+
end
|
29
|
+
def to_env_s
|
30
|
+
nil
|
31
|
+
end
|
32
|
+
def clean!
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Envo
|
2
|
+
class PathListVal < ListVal
|
3
|
+
def initialize(host, ar)
|
4
|
+
super(ar)
|
5
|
+
@host = host
|
6
|
+
end
|
7
|
+
def type
|
8
|
+
:"path list"
|
9
|
+
end
|
10
|
+
def accept_assign?(other)
|
11
|
+
other.type == type
|
12
|
+
end
|
13
|
+
def accept_item?(item)
|
14
|
+
item.type == :path
|
15
|
+
end
|
16
|
+
def pp_attribs(elem)
|
17
|
+
super + (@host.path_exists?(elem) ? ' ' : 'N')
|
18
|
+
end
|
19
|
+
def clean!
|
20
|
+
super
|
21
|
+
@ar.select! { |s| @host.path_exists?(s) }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Envo
|
2
|
+
class PathVal
|
3
|
+
def initialize(host, str)
|
4
|
+
@host = host
|
5
|
+
@path = str
|
6
|
+
end
|
7
|
+
attr_reader :host
|
8
|
+
attr_accessor :path
|
9
|
+
# casts
|
10
|
+
def type
|
11
|
+
:path
|
12
|
+
end
|
13
|
+
def accept_assign?(other)
|
14
|
+
other.type == type
|
15
|
+
end
|
16
|
+
def invalid_description
|
17
|
+
@host.path_exists?(@path) ? nil : 'non-existing path'
|
18
|
+
end
|
19
|
+
def list?
|
20
|
+
false
|
21
|
+
end
|
22
|
+
def to_list
|
23
|
+
return PathListVal.new(@host, [@path])
|
24
|
+
end
|
25
|
+
def to_s
|
26
|
+
@path
|
27
|
+
end
|
28
|
+
def pretty_print(ctx)
|
29
|
+
ctx.puts @path
|
30
|
+
inv = invalid_description
|
31
|
+
return if !inv
|
32
|
+
ctx.warn "Warning: #{inv}"
|
33
|
+
end
|
34
|
+
def to_env_s
|
35
|
+
@path
|
36
|
+
end
|
37
|
+
def clean!
|
38
|
+
@path = nil if @path && !@path.empty? && !@host.path_exists?(@path)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Envo
|
2
|
+
class StringVal
|
3
|
+
def initialize(str)
|
4
|
+
@value = str
|
5
|
+
end
|
6
|
+
attr_accessor :value
|
7
|
+
|
8
|
+
# casts
|
9
|
+
def type
|
10
|
+
:string
|
11
|
+
end
|
12
|
+
def accept_assign?(other)
|
13
|
+
true
|
14
|
+
end
|
15
|
+
def invalid_description
|
16
|
+
@value.empty? ? "empty string" : nil
|
17
|
+
end
|
18
|
+
def list?
|
19
|
+
false
|
20
|
+
end
|
21
|
+
def to_list
|
22
|
+
return ListVal.new([@value])
|
23
|
+
end
|
24
|
+
def to_s
|
25
|
+
@value
|
26
|
+
end
|
27
|
+
def pretty_print(ctx)
|
28
|
+
ctx.puts @value
|
29
|
+
inv = invalid_description
|
30
|
+
return if !inv
|
31
|
+
ctx.warn "Warning: #{inv}"
|
32
|
+
end
|
33
|
+
def to_env_s
|
34
|
+
@value
|
35
|
+
end
|
36
|
+
def clean!
|
37
|
+
@value = nil if @value && @value.empty?
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
3
|
+
module Envo
|
4
|
+
module ValBuilder
|
5
|
+
extend self
|
6
|
+
|
7
|
+
def from_env_string(str, host)
|
8
|
+
return NoVal.new if !str
|
9
|
+
|
10
|
+
is_list = host.shell.likely_list?(str)
|
11
|
+
is_path = host.shell.likely_abs_path?(str)
|
12
|
+
|
13
|
+
if is_list
|
14
|
+
ar = host.shell.list_to_ar(str)
|
15
|
+
if is_path
|
16
|
+
return PathListVal.new(host, ar)
|
17
|
+
else
|
18
|
+
return ListVal.new(ar)
|
19
|
+
end
|
20
|
+
elsif is_path
|
21
|
+
return PathVal.new(host, str)
|
22
|
+
else
|
23
|
+
return StringVal.new(str)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def from_user_string(str, host)
|
28
|
+
if host.shell.likely_abs_path?(str)
|
29
|
+
return PathVal.new(host, host.shell.fix_path(str))
|
30
|
+
end
|
31
|
+
|
32
|
+
if host.shell.likely_rel_path?(str)
|
33
|
+
# the pathname approach is not multi-platform
|
34
|
+
# ie windows paths won't work on non-windows host
|
35
|
+
# we should reimplement pathname joins for windows for this to work
|
36
|
+
path = Pathname.new host.pwd
|
37
|
+
path += str
|
38
|
+
return PathVal.new(host, host.shell.fix_path(path.cleanpath.to_s))
|
39
|
+
end
|
40
|
+
|
41
|
+
return StringVal.new str
|
42
|
+
end
|
43
|
+
|
44
|
+
def from_user_text(text, host)
|
45
|
+
return from_user_string(text, host) if text.class != Array
|
46
|
+
return NoVal.new if text.empty?
|
47
|
+
|
48
|
+
elems = text.map { |str| from_user_string(str, host) }
|
49
|
+
|
50
|
+
# array of 1 is as good as nothing
|
51
|
+
return elems[0] if elems.size == 1
|
52
|
+
|
53
|
+
is_path = elems[0].type == :path
|
54
|
+
elems.map! { |elem| elem.to_s }
|
55
|
+
|
56
|
+
return is_path ? PathListVal.new(host, elems) : ListVal.new(elems)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/lib/envo/version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: envo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Borislav Stanimirov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-11-14 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: View, set, unset and manage environment variables (strings, lists, paths)
|
14
|
+
on all platforms.
|
15
|
+
email: b.stanimirov@abv.bg
|
16
|
+
executables:
|
17
|
+
- envo-install
|
18
|
+
- envo_run
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- bin/envo-install
|
23
|
+
- bin/envo_gen_tmp_helper.rb
|
24
|
+
- bin/envo_run
|
25
|
+
- lib/envo.rb
|
26
|
+
- lib/envo/cli/envo.bat
|
27
|
+
- lib/envo/cli/envo.sh
|
28
|
+
- lib/envo/cli/help.rb
|
29
|
+
- lib/envo/cli/installer_bash.rb
|
30
|
+
- lib/envo/cli/installer_win_cmd.rb
|
31
|
+
- lib/envo/cli/runner.rb
|
32
|
+
- lib/envo/cli_parser.rb
|
33
|
+
- lib/envo/cmd_clean.rb
|
34
|
+
- lib/envo/cmd_copy.rb
|
35
|
+
- lib/envo/cmd_list.rb
|
36
|
+
- lib/envo/cmd_list_add.rb
|
37
|
+
- lib/envo/cmd_list_del.rb
|
38
|
+
- lib/envo/cmd_path.rb
|
39
|
+
- lib/envo/cmd_reset.rb
|
40
|
+
- lib/envo/cmd_run.rb
|
41
|
+
- lib/envo/cmd_set.rb
|
42
|
+
- lib/envo/cmd_show.rb
|
43
|
+
- lib/envo/cmd_swap.rb
|
44
|
+
- lib/envo/cmd_unset.rb
|
45
|
+
- lib/envo/context.rb
|
46
|
+
- lib/envo/error.rb
|
47
|
+
- lib/envo/host.rb
|
48
|
+
- lib/envo/host_shell.rb
|
49
|
+
- lib/envo/logger.rb
|
50
|
+
- lib/envo/parse_result.rb
|
51
|
+
- lib/envo/parsed_cmd.rb
|
52
|
+
- lib/envo/script_parser.rb
|
53
|
+
- lib/envo/shell/bash.rb
|
54
|
+
- lib/envo/shell/win_cmd.rb
|
55
|
+
- lib/envo/state.rb
|
56
|
+
- lib/envo/val/list_val.rb
|
57
|
+
- lib/envo/val/no_val.rb
|
58
|
+
- lib/envo/val/path_list_val.rb
|
59
|
+
- lib/envo/val/path_val.rb
|
60
|
+
- lib/envo/val/string_val.rb
|
61
|
+
- lib/envo/val/val_builder.rb
|
62
|
+
- lib/envo/version.rb
|
63
|
+
homepage: https://github.com/iboB/envo
|
64
|
+
licenses:
|
65
|
+
- MIT
|
66
|
+
metadata: {}
|
67
|
+
post_install_message: |
|
68
|
+
Thanks for installing envo!
|
69
|
+
For this tool to work, you must also run the installation program: 'envo-install'.
|
70
|
+
Running it will complete the setup and 'envo' should be available as a command.
|
71
|
+
rdoc_options: []
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
requirements: []
|
85
|
+
rubygems_version: 3.1.4
|
86
|
+
signing_key:
|
87
|
+
specification_version: 4
|
88
|
+
summary: An CLI environment variable manager
|
89
|
+
test_files: []
|