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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b3c78893dfac17f4ac980d8ef837579e2d201ecb6799d4874ff188e915948d5a
4
- data.tar.gz: 6287b866816e95c5d51cab808e64dd327f3ff5017379c2799d5ee06002f6dc3d
3
+ metadata.gz: 0fe90f1db0d7da40f484573c95ee3b534dcd2e60b1ffe33e12beef901f134a7c
4
+ data.tar.gz: 6f4d4c221df0642d2e9873770c75520ce2a629f41b2d64fb225c75f07f17948d
5
5
  SHA512:
6
- metadata.gz: a4b6a4c2df65fc9fff845aab62850a0f8d45f55279d9b5e569895689b1872f7e814e9d49fd378edf86b7a48af58ebc7b959022257e38885b42ba535bb591349f
7
- data.tar.gz: 3c87e5f8e8c4722a14d3d9299fb8fc43a411ed1b394ab614f72a82975d98fd525d4f6aa43911b3a95e2c196d903e84b65826b10c3eade4af165a1a954073075d
6
+ metadata.gz: 8cf8cf8ab7e644dd633d60f0fb9bfd418453340f210a8b49ebd2713af589e472e052d39779f43e0adba3e11c4c7f2d311b6669acb3ed94fbe3a96f48bb5b093d
7
+ data.tar.gz: 1b0183a301605c9996efba79a8c2fb8f5fe2aacd241d074b97b5d5c9f367f0c45dc6566ba13f79b806f43c670f60471cb6b1d4264b6d444d76e311060d8afc0d
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.7
1
+ 0.3.8
@@ -5,6 +5,7 @@
5
5
  module Simple::CLI
6
6
  module Helper
7
7
  def help_on_command!(service, command, verbose:)
8
+ _ = verbose
8
9
  action = H.action_for_command(service, command)
9
10
 
10
11
  parts = [
@@ -1,3 +1,5 @@
1
+ # rubocop:disable Metrics/AbcSize
2
+
1
3
  module Simple::CLI
2
4
  module Helper
3
5
  def short_help!(service)
@@ -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
@@ -1,3 +1,7 @@
1
+ # rubocop:disable Metrics/CyclomaticComplexity
2
+ # rubocop:disable Metrics/MethodLength
3
+ # rubocop:disable Metrics/PerceivedComplexity
4
+
1
5
  module Simple::CLI
2
6
  module Runner
3
7
  extend self
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ # rubocop:disable Style/GlobalVars
4
+
3
5
  # -- helpers ------------------------------------------------------------------
4
6
 
5
7
  def sys(cmd)
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.7
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-11 00:00:00.000000000 Z
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.6
136
+ rubygems_version: 3.0.2
137
137
  signing_key:
138
138
  specification_version: 4
139
139
  summary: Simple CLI builder for ruby