simple-cli 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/simple/cli/helpers.rb +11 -0
- data/lib/simple/cli/runner.rb +6 -4
- data/lib/simple/cli/runner/autocompletion.rb +5 -1
- data/lib/simple/cli/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2bbb7f97dbbfd4da167b579db74edf64e58f696
|
4
|
+
data.tar.gz: 3fa71c9effb4830a2542d11562767c67da9f2f95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbf7773b19c487d395706b84b9ea35d59ff9fd11b63b2adf2624375d0212d9ceec8ea55b154f68be4e71fb16ec06f9d177ad178f15a34b464298c5908e1ab0b7
|
7
|
+
data.tar.gz: f6ee3a7d40c9dd6eb3849625294b17c2cbe5f096b5d7c78a34b0292a67af436fefb12e60b6997acddd3c0f9d36d66d4218064690413ac8495acd9bb0c5511497
|
data/Gemfile.lock
CHANGED
data/lib/simple/cli/helpers.rb
CHANGED
@@ -18,6 +18,17 @@ module Simple::CLI::Helpers
|
|
18
18
|
::Simple::CLI.logger
|
19
19
|
end
|
20
20
|
|
21
|
+
SSH = "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
|
22
|
+
|
23
|
+
def ssh_command(host, user: nil)
|
24
|
+
host = "#{user}@#{host}" if user
|
25
|
+
"#{SSH} #{host}"
|
26
|
+
end
|
27
|
+
|
28
|
+
def ssh!(target, command, user: nil)
|
29
|
+
sys! "#{ssh_command(target, user: user)} #{command}"
|
30
|
+
end
|
31
|
+
|
21
32
|
def sh!(cmd, *args)
|
22
33
|
command = Command.new(cmd, *args)
|
23
34
|
result = command.sh
|
data/lib/simple/cli/runner.rb
CHANGED
@@ -144,6 +144,7 @@ class Simple::CLI::Runner
|
|
144
144
|
command_help = command_helps.fetch(sym)
|
145
145
|
command_help = format("%-#{max_command_helps_length}s", command_help)
|
146
146
|
edoc = CommandHelp.new(@app, sym)
|
147
|
+
next if !edoc.head && logger.level != ::Logger::DEBUG
|
147
148
|
head = "# #{edoc.head}" if edoc.head
|
148
149
|
STDERR.puts " #{command_help} #{head}"
|
149
150
|
end
|
@@ -153,10 +154,11 @@ class Simple::CLI::Runner
|
|
153
154
|
STDERR.puts <<~DOC
|
154
155
|
Default options include:
|
155
156
|
|
156
|
-
#{binary_name} [ --verbose | -v ]
|
157
|
-
#{binary_name} [ --quiet | -q ]
|
158
|
-
#{binary_name} help [ subcommand ]
|
159
|
-
#{binary_name} help autocomplete
|
157
|
+
#{binary_name} [ --verbose | -v ] # run on DEBUG log level
|
158
|
+
#{binary_name} [ --quiet | -q ] # run on WARN log level
|
159
|
+
#{binary_name} help [ subcommand ] # print help on a specific subcommand
|
160
|
+
#{binary_name} help autocomplete # print information on autocompletion.
|
161
|
+
#{binary_name} help -v # show help for internal commands as well
|
160
162
|
|
161
163
|
DOC
|
162
164
|
|
@@ -30,12 +30,16 @@ module Simple::CLI::Runner::Autocompletion
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
+
DEFAULT_OPTIONS = %w(--verbose -v --quiet -q)
|
34
|
+
|
33
35
|
def autocomplete_subcommand_options(subcommand, cur)
|
34
36
|
if subcommand == "help"
|
35
37
|
completions = commands.map(&:to_s).map { |s| s.tr("_", ":") } + ["autocomplete"]
|
36
38
|
filter_completions completions, prefix: cur
|
37
|
-
elsif cur[0,1] == "-"
|
39
|
+
elsif cur && cur[0,1] == "-"
|
38
40
|
completions = CommandHelp.option_names(@app, string_to_command(subcommand))
|
41
|
+
completions += DEFAULT_OPTIONS
|
42
|
+
|
39
43
|
filter_completions completions, prefix: cur
|
40
44
|
else
|
41
45
|
Dir.glob "#{cur}*"
|
data/lib/simple/cli/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- radiospiel
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-02-
|
12
|
+
date: 2018-02-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|