enfcli 4.0.0 → 5.0.0.pre.alpha
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/.circleci/Dockerfile +2 -2
- data/.circleci/config.yml +5 -0
- data/Gemfile.lock +38 -26
- data/Makefile +7 -0
- data/README.md +52 -7
- data/enfcli.gemspec +28 -26
- data/format.sh +9 -0
- data/lib/enfapi.rb +184 -237
- data/lib/enfapi/dns.rb +95 -0
- data/lib/enfapi/firewall.rb +37 -0
- data/lib/enfapi/user.rb +75 -0
- data/lib/enfcli.rb +211 -111
- data/lib/enfcli/commands/captive.rb +518 -157
- data/lib/enfcli/commands/user.rb +208 -160
- data/lib/enfcli/commands/xcr.rb +151 -119
- data/lib/enfcli/commands/xdns.rb +65 -55
- data/lib/enfcli/commands/xfw.rb +37 -37
- data/lib/enfcli/commands/xiam.rb +87 -80
- data/lib/enfcli/version.rb +2 -2
- data/lib/enfthor.rb +38 -14
- metadata +65 -5
data/lib/enfthor.rb
CHANGED
@@ -13,8 +13,8 @@
|
|
13
13
|
# See the License for the specific language governing permissions and
|
14
14
|
# limitations under the License.
|
15
15
|
#
|
16
|
-
require
|
17
|
-
require
|
16
|
+
require "thor"
|
17
|
+
require "terminal-table"
|
18
18
|
|
19
19
|
module EnfCli
|
20
20
|
class EnfThor < Thor
|
@@ -23,9 +23,8 @@ module EnfCli
|
|
23
23
|
|
24
24
|
# helper functions
|
25
25
|
no_commands {
|
26
|
-
|
27
26
|
def format_date(date)
|
28
|
-
DateTime.strptime("#{date}",
|
27
|
+
DateTime.strptime("#{date}", "%s") if date
|
29
28
|
end
|
30
29
|
|
31
30
|
def render_table(headings, rows, file = nil)
|
@@ -33,7 +32,7 @@ module EnfCli
|
|
33
32
|
table.headings = headings
|
34
33
|
table.rows = rows
|
35
34
|
if file
|
36
|
-
open(expand_path(file),
|
35
|
+
open(expand_path(file), "w") { |f|
|
37
36
|
f.puts table
|
38
37
|
}
|
39
38
|
say "#{rows.length} rows written to file #{file}", :yellow
|
@@ -58,17 +57,13 @@ module EnfCli
|
|
58
57
|
yield
|
59
58
|
rescue EnfApi::ERROR => e
|
60
59
|
say e, :red
|
61
|
-
|
62
60
|
rescue OpenSSL::SSL::SSLError => e
|
63
61
|
say e, :red
|
64
62
|
say "Host may not support https. Try http instead", :bold
|
65
|
-
|
66
63
|
rescue => e
|
67
64
|
say e, :red
|
68
65
|
end
|
69
66
|
end
|
70
|
-
|
71
|
-
|
72
67
|
}
|
73
68
|
|
74
69
|
# override help methods
|
@@ -81,6 +76,37 @@ module EnfCli
|
|
81
76
|
text
|
82
77
|
end
|
83
78
|
|
79
|
+
def handle_argument_error(command, error, args, arity)
|
80
|
+
begin
|
81
|
+
super(command, error, args, arity)
|
82
|
+
rescue Thor::InvocationError => e
|
83
|
+
msg = "#{e}"
|
84
|
+
msg = msg.gsub(/enfcli /, "") unless self == EnfCli::CLI
|
85
|
+
raise Thor::InvocationError, msg
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def command_help(shell, command_name)
|
90
|
+
meth = normalize_command_name(command_name)
|
91
|
+
command = all_commands[meth]
|
92
|
+
handle_no_command_error(meth) unless command
|
93
|
+
|
94
|
+
## HACK: format to display proper help message for help command run from shell
|
95
|
+
banner_text = banner(command)
|
96
|
+
banner_text = banner_text.gsub(/enfcli /, "") unless self == EnfCli::CLI
|
97
|
+
|
98
|
+
shell.say "Usage:"
|
99
|
+
shell.say " #{banner_text}"
|
100
|
+
shell.say
|
101
|
+
class_options_help(shell, nil => command.options.values)
|
102
|
+
if command.long_description
|
103
|
+
shell.say "Description:"
|
104
|
+
shell.print_wrapped(command.long_description, :indent => 2)
|
105
|
+
else
|
106
|
+
shell.say command.description
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
84
110
|
def help(shell, subcommand = false)
|
85
111
|
list = printable_commands(true, subcommand)
|
86
112
|
Thor::Util.thor_classes_in(self).each do |klass|
|
@@ -91,8 +117,7 @@ module EnfCli
|
|
91
117
|
list.sort! { |a, b| a[0] <=> b[0] }
|
92
118
|
|
93
119
|
# Add this line to remove the help-command itself from the output
|
94
|
-
list.reject! {|l| l[0].split[1] ==
|
95
|
-
|
120
|
+
list.reject! { |l| l[0].split[1] == "help" or l[0].split[2] == "help" }
|
96
121
|
|
97
122
|
# Capture help message in a variable
|
98
123
|
help_text = capture_stdout {
|
@@ -103,16 +128,15 @@ module EnfCli
|
|
103
128
|
}
|
104
129
|
|
105
130
|
## HACK: format to display proper help message for help command run from shell
|
106
|
-
help_text = help_text.gsub(/enfcli /,"") unless self == EnfCli::CLI
|
131
|
+
help_text = help_text.gsub(/enfcli /, "") unless self == EnfCli::CLI
|
107
132
|
|
108
133
|
# Print the actual help message
|
109
134
|
shell.say help_text
|
110
135
|
|
111
136
|
# Add this line if you want to print custom text at the end of your help output.
|
112
137
|
# (similar to how Rails does it)
|
113
|
-
shell.say
|
138
|
+
shell.say "All commands can be run with -h (or --help) for more information."
|
114
139
|
end
|
115
140
|
end
|
116
|
-
|
117
141
|
end
|
118
142
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: enfcli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.0.0.pre.alpha
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Venkatakumar Srinivasan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -52,6 +52,48 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: clipboard
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: ffi
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: readline
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
55
97
|
- !ruby/object:Gem::Dependency
|
56
98
|
name: bundler
|
57
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -164,6 +206,20 @@ dependencies:
|
|
164
206
|
- - ">="
|
165
207
|
- !ruby/object:Gem::Version
|
166
208
|
version: '0'
|
209
|
+
- !ruby/object:Gem::Dependency
|
210
|
+
name: rufo
|
211
|
+
requirement: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - ">="
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '0'
|
216
|
+
type: :development
|
217
|
+
prerelease: false
|
218
|
+
version_requirements: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - ">="
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: '0'
|
167
223
|
description:
|
168
224
|
email:
|
169
225
|
- venkat@xaptum.com
|
@@ -185,7 +241,11 @@ files:
|
|
185
241
|
- Rakefile
|
186
242
|
- bin/enfcli
|
187
243
|
- enfcli.gemspec
|
244
|
+
- format.sh
|
188
245
|
- lib/enfapi.rb
|
246
|
+
- lib/enfapi/dns.rb
|
247
|
+
- lib/enfapi/firewall.rb
|
248
|
+
- lib/enfapi/user.rb
|
189
249
|
- lib/enfcli.rb
|
190
250
|
- lib/enfcli/commands/captive.rb
|
191
251
|
- lib/enfcli/commands/user.rb
|
@@ -209,11 +269,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
209
269
|
version: '0'
|
210
270
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
211
271
|
requirements:
|
212
|
-
- - "
|
272
|
+
- - ">"
|
213
273
|
- !ruby/object:Gem::Version
|
214
|
-
version:
|
274
|
+
version: 1.3.1
|
215
275
|
requirements: []
|
216
|
-
rubygems_version: 3.0.
|
276
|
+
rubygems_version: 3.0.3
|
217
277
|
signing_key:
|
218
278
|
specification_version: 4
|
219
279
|
summary: Xaptum ENF CLI.
|