simple-cli 0.3.7 → 0.3.8
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/VERSION +1 -1
- data/lib/simple/cli/helper/help_on_command.rb +1 -0
- data/lib/simple/cli/helper/short_help.rb +2 -0
- data/lib/simple/cli/logger/colored_logger.rb +29 -1
- data/lib/simple/cli/runner.rb +4 -0
- data/scripts/release.rb +2 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0fe90f1db0d7da40f484573c95ee3b534dcd2e60b1ffe33e12beef901f134a7c
|
4
|
+
data.tar.gz: 6f4d4c221df0642d2e9873770c75520ce2a629f41b2d64fb225c75f07f17948d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8cf8cf8ab7e644dd633d60f0fb9bfd418453340f210a8b49ebd2713af589e472e052d39779f43e0adba3e11c4c7f2d311b6669acb3ed94fbe3a96f48bb5b093d
|
7
|
+
data.tar.gz: 1b0183a301605c9996efba79a8c2fb8f5fe2aacd241d074b97b5d5c9f367f0c45dc6566ba13f79b806f43c670f60471cb6b1d4264b6d444d76e311060d8afc0d
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.8
|
@@ -4,6 +4,8 @@
|
|
4
4
|
# rubocop:disable Metrics/CyclomaticComplexity
|
5
5
|
# rubocop:disable Metrics/PerceivedComplexity
|
6
6
|
|
7
|
+
require "pathname"
|
8
|
+
|
7
9
|
module Simple::CLI::Logger::ColoredLogger
|
8
10
|
extend self
|
9
11
|
|
@@ -118,12 +120,38 @@ module Simple::CLI::Logger::ColoredLogger
|
|
118
120
|
if log_level < Logger::INFO
|
119
121
|
padding = " " * (90 - msg_length) if msg_length < 90
|
120
122
|
msg = "#{msg}#{padding}"
|
121
|
-
msg = "#{msg}from #{source_from_caller}"
|
123
|
+
msg = "#{msg}from #{shorten_path source_from_caller}"
|
122
124
|
end
|
123
125
|
|
124
126
|
STDERR.puts msg
|
125
127
|
end
|
126
128
|
|
129
|
+
def shorten_path(path)
|
130
|
+
@pwd ||= File.join(Dir.getwd, "/")
|
131
|
+
@home ||= File.join(Dir.home, "/")
|
132
|
+
|
133
|
+
path = File.absolute_path(path)
|
134
|
+
|
135
|
+
if path.start_with?(@pwd)
|
136
|
+
path = path[@pwd.length..-1]
|
137
|
+
path = File.join("./", path) if path =~ /\//
|
138
|
+
return path
|
139
|
+
end
|
140
|
+
|
141
|
+
relative_path = relative_path_from_here(path)
|
142
|
+
|
143
|
+
if path.start_with?(@home)
|
144
|
+
path = File.join("~/", path[@home.length..-1])
|
145
|
+
end
|
146
|
+
|
147
|
+
path.length < relative_path.length ? path : relative_path
|
148
|
+
end
|
149
|
+
|
150
|
+
def relative_path_from_here(absolute_path)
|
151
|
+
@pwd_pathname ||= Pathname.new(@pwd)
|
152
|
+
Pathname.new(absolute_path).relative_path_from(@pwd_pathname).to_s
|
153
|
+
end
|
154
|
+
|
127
155
|
# The heuristic used to determine the caller is not perfect, but should
|
128
156
|
# do well in most cases.
|
129
157
|
def source_from_caller
|
data/lib/simple/cli/runner.rb
CHANGED
data/scripts/release.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.3.
|
4
|
+
version: 0.3.8
|
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: 2019-12-
|
12
|
+
date: 2019-12-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: simple-service
|
@@ -133,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
133
|
- !ruby/object:Gem::Version
|
134
134
|
version: '0'
|
135
135
|
requirements: []
|
136
|
-
rubygems_version: 3.0.
|
136
|
+
rubygems_version: 3.0.2
|
137
137
|
signing_key:
|
138
138
|
specification_version: 4
|
139
139
|
summary: Simple CLI builder for ruby
|