gum 0.3.1-arm64-darwin → 0.3.2-arm64-darwin

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: f4ccc96a67858754d587292d7446f956bc0f8c4aad0d42db8a2b18142e4dd9e7
4
- data.tar.gz: d67076ee2f37793ffb239332d29a4a268a5875d1b39e321e7a61fd949aa7d24c
3
+ metadata.gz: '0501598cd6d46cffa2d6d0c6b6ab58f98eef51ad1d7bb2b2f4b81fa789946cdb'
4
+ data.tar.gz: 384fb147853fea0f295495d637d46ebf0c885ba9153478505de2046a29dfebe4
5
5
  SHA512:
6
- metadata.gz: 963b8b8ec695444f741e0b1fbeebcf518a6cff1e94f01c35bd4240d42c4868d95937ea37b6e72b4526db6d5ac426a7688d63c083f792f0ac8561ec16b84cda91
7
- data.tar.gz: 9b1b59a2be6e7e5afbd0a9ad3df78a6d93ca3e367bf4a89f625c82b20025992261ea80926e176c6418bdb66efc4ce52931c4b133c991886f2e6f977179b84d13
6
+ metadata.gz: 33f806c016e2fe0f2ca532f1002be3fa052acf7ea1092a9a14da879446ca92e47fcc7fb1f7de16e3860b14c6c0cf1002b2758ca3c964779db982b701fd6f90db
7
+ data.tar.gz: '0948394630b5716a504d1e7b6dde203ffacad06f58e4e57c5c48cca0cc0b99da99bf0ce524d1c1c43139ee5ffe31565b54e7e3f0384dc8bf64dc29d3aeb94672'
data/exe/gum CHANGED
@@ -4,8 +4,7 @@
4
4
  # Because rubygems shims assume a gem's executables are Ruby scripts,
5
5
  # we need this wrapper to find and exec the native gum binary.
6
6
 
7
- $LOAD_PATH.unshift(File.expand_path("../lib", __dir__))
8
-
7
+ require "bundler/setup"
9
8
  require "gum"
10
9
 
11
10
  exec(Gum.executable, *ARGV)
data/lib/gum/command.rb CHANGED
@@ -7,9 +7,9 @@ require "open3"
7
7
 
8
8
  module Gum
9
9
  module Command
10
- def self.run(*, input: nil, interactive: true)
10
+ def self.run(*, input: nil, interactive: true, output: :stdout)
11
11
  if !interactive
12
- run_non_interactive(*, input: input)
12
+ run_non_interactive(*, input: input, output: output)
13
13
  elsif input
14
14
  run_interactive_with_input(*, input: input)
15
15
  else
@@ -17,8 +17,8 @@ module Gum
17
17
  end
18
18
  end
19
19
 
20
- def self.run_non_interactive(*args, input:)
21
- stdout, stderr, status = Open3.capture3(Gum.executable, *args.map(&:to_s), stdin_data: input)
20
+ def self.run_non_interactive(*args, input:, output: :stdout)
21
+ stdout, stderr, status = Open3.capture3(color_env, Gum.executable, *args.map(&:to_s), stdin_data: input)
22
22
 
23
23
  unless status.success?
24
24
  return nil if status.exitstatus == 130 # User cancelled (Ctrl+C)
@@ -26,14 +26,14 @@ module Gum
26
26
  raise Error, "gum #{args.first} failed: #{stderr}" unless stderr.empty?
27
27
  end
28
28
 
29
- stdout.chomp
29
+ (output == :stderr ? stderr : stdout).chomp
30
30
  end
31
31
 
32
32
  def self.run_interactive(*args)
33
33
  tty = File.open("/dev/tty", "r+")
34
34
 
35
35
  stdout, wait_thread = Open3.pipeline_r(
36
- [Gum.executable, *args.map(&:to_s)],
36
+ [color_env, Gum.executable, *args.map(&:to_s)],
37
37
  in: tty,
38
38
  err: tty
39
39
  )
@@ -48,7 +48,7 @@ module Gum
48
48
 
49
49
  output
50
50
  rescue Errno::ENOENT, Errno::ENXIO, Errno::EIO
51
- stdout, stderr, status = Open3.capture3(Gum.executable, *args.map(&:to_s))
51
+ stdout, stderr, status = Open3.capture3(color_env, Gum.executable, *args.map(&:to_s))
52
52
 
53
53
  unless status.success?
54
54
  return nil if status.exitstatus == 130
@@ -64,6 +64,7 @@ module Gum
64
64
  stdout_read, stdout_write = IO.pipe
65
65
 
66
66
  pid = Process.spawn(
67
+ color_env,
67
68
  Gum.executable, *args.map(&:to_s),
68
69
  in: stdin_read,
69
70
  out: stdout_write,
@@ -91,7 +92,7 @@ module Gum
91
92
  end
92
93
 
93
94
  def self.run_display_only(*args, input:)
94
- IO.popen([Gum.executable, *args.map(&:to_s)], "w") do |io|
95
+ IO.popen([color_env, Gum.executable, *args.map(&:to_s)], "w") do |io|
95
96
  io.write(input)
96
97
  end
97
98
 
@@ -102,10 +103,10 @@ module Gum
102
103
 
103
104
  def self.run_with_status(*args, input: nil)
104
105
  if input
105
- _stdout, _stderr, status = Open3.capture3(Gum.executable, *args.map(&:to_s), stdin_data: input)
106
+ _stdout, _stderr, status = Open3.capture3(color_env, Gum.executable, *args.map(&:to_s), stdin_data: input)
106
107
  status.success?
107
108
  else
108
- system(Gum.executable, *args.map(&:to_s))
109
+ system(color_env, Gum.executable, *args.map(&:to_s))
109
110
  end
110
111
  end
111
112
 
@@ -155,5 +156,9 @@ module Gum
155
156
 
156
157
  negatable.fetch(command, []).include?(flag)
157
158
  end
159
+
160
+ def self.color_env
161
+ $stdout.tty? ? { "CLICOLOR_FORCE" => "1" } : {}
162
+ end
158
163
  end
159
164
  end
@@ -30,7 +30,7 @@ module Gum
30
30
  # @rbs formatter: Symbol | String | nil -- log formatter (:text, :json, :logfmt)
31
31
  # @rbs prefix: String? -- log message prefix
32
32
  # @rbs **fields: untyped -- additional key-value fields for structured logging
33
- # @rbs return: String? -- formatted log output
33
+ # @rbs return: bool -- true if logging succeeded
34
34
  def self.call(
35
35
  message,
36
36
  level: nil,
@@ -57,40 +57,40 @@ module Gum
57
57
  args << value.to_s
58
58
  end
59
59
 
60
- Command.run(*args, interactive: false)
60
+ Command.run_with_status(*args)
61
61
  end
62
62
 
63
63
  # @rbs message: String -- log message text
64
64
  # @rbs **fields: untyped -- additional key-value fields
65
- # @rbs return: String? -- formatted debug log output
65
+ # @rbs return: bool -- true if logging succeeded
66
66
  def self.debug(message, **fields)
67
67
  call(message, level: :debug, **fields)
68
68
  end
69
69
 
70
70
  # @rbs message: String -- log message text
71
71
  # @rbs **fields: untyped -- additional key-value fields
72
- # @rbs return: String? -- formatted info log output
72
+ # @rbs return: bool -- true if logging succeeded
73
73
  def self.info(message, **fields)
74
74
  call(message, level: :info, **fields)
75
75
  end
76
76
 
77
77
  # @rbs message: String -- log message text
78
78
  # @rbs **fields: untyped -- additional key-value fields
79
- # @rbs return: String? -- formatted warn log output
79
+ # @rbs return: bool -- true if logging succeeded
80
80
  def self.warn(message, **fields)
81
81
  call(message, level: :warn, **fields)
82
82
  end
83
83
 
84
84
  # @rbs message: String -- log message text
85
85
  # @rbs **fields: untyped -- additional key-value fields
86
- # @rbs return: String? -- formatted error log output
86
+ # @rbs return: bool -- true if logging succeeded
87
87
  def self.error(message, **fields)
88
88
  call(message, level: :error, **fields)
89
89
  end
90
90
 
91
91
  # @rbs message: String -- log message text
92
92
  # @rbs **fields: untyped -- additional key-value fields
93
- # @rbs return: String? -- formatted fatal log output
93
+ # @rbs return: bool -- true if logging succeeded
94
94
  def self.fatal(message, **fields)
95
95
  call(message, level: :fatal, **fields)
96
96
  end
data/lib/gum/version.rb CHANGED
@@ -3,5 +3,5 @@
3
3
  # rbs_inline: enabled
4
4
 
5
5
  module Gum
6
- VERSION = "0.3.1"
6
+ VERSION = "0.3.2"
7
7
  end
data/lib/gum.rb CHANGED
@@ -31,7 +31,7 @@ module Gum
31
31
 
32
32
  class << self
33
33
  def execute(*args)
34
- system(executable, *args.map(&:to_s))
34
+ system(Command.color_env, executable, *args.map(&:to_s))
35
35
  end
36
36
 
37
37
  def platform
data/sig/gum/command.rbs CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  module Gum
4
4
  module Command
5
- def self.run: (*untyped, ?input: untyped, ?interactive: untyped) -> untyped
5
+ def self.run: (*untyped, ?input: untyped, ?interactive: untyped, ?output: untyped) -> untyped
6
6
 
7
- def self.run_non_interactive: (*untyped args, input: untyped) -> untyped
7
+ def self.run_non_interactive: (*untyped args, input: untyped, ?output: untyped) -> untyped
8
8
 
9
9
  def self.run_interactive: (*untyped args) -> untyped
10
10
 
@@ -19,5 +19,7 @@ module Gum
19
19
  def self.add_style_args: (untyped args, untyped flag, untyped style_hash) -> untyped
20
20
 
21
21
  def self.flag_supports_negation?: (untyped command, untyped flag) -> untyped
22
+
23
+ def self.color_env: () -> untyped
22
24
  end
23
25
  end
@@ -25,32 +25,32 @@ module Gum
25
25
  # @rbs formatter: Symbol | String | nil -- log formatter (:text, :json, :logfmt)
26
26
  # @rbs prefix: String? -- log message prefix
27
27
  # @rbs **fields: untyped -- additional key-value fields for structured logging
28
- # @rbs return: String? -- formatted log output
29
- def self.call: (String message, ?level: Symbol | String | nil, ?time: Symbol | String | nil, ?structured: bool?, ?formatter: Symbol | String | nil, ?prefix: String?, **untyped fields) -> String?
28
+ # @rbs return: bool -- true if logging succeeded
29
+ def self.call: (String message, ?level: Symbol | String | nil, ?time: Symbol | String | nil, ?structured: bool?, ?formatter: Symbol | String | nil, ?prefix: String?, **untyped fields) -> bool
30
30
 
31
31
  # @rbs message: String -- log message text
32
32
  # @rbs **fields: untyped -- additional key-value fields
33
- # @rbs return: String? -- formatted debug log output
34
- def self.debug: (String message, **untyped fields) -> String?
33
+ # @rbs return: bool -- true if logging succeeded
34
+ def self.debug: (String message, **untyped fields) -> bool
35
35
 
36
36
  # @rbs message: String -- log message text
37
37
  # @rbs **fields: untyped -- additional key-value fields
38
- # @rbs return: String? -- formatted info log output
39
- def self.info: (String message, **untyped fields) -> String?
38
+ # @rbs return: bool -- true if logging succeeded
39
+ def self.info: (String message, **untyped fields) -> bool
40
40
 
41
41
  # @rbs message: String -- log message text
42
42
  # @rbs **fields: untyped -- additional key-value fields
43
- # @rbs return: String? -- formatted warn log output
44
- def self.warn: (String message, **untyped fields) -> String?
43
+ # @rbs return: bool -- true if logging succeeded
44
+ def self.warn: (String message, **untyped fields) -> bool
45
45
 
46
46
  # @rbs message: String -- log message text
47
47
  # @rbs **fields: untyped -- additional key-value fields
48
- # @rbs return: String? -- formatted error log output
49
- def self.error: (String message, **untyped fields) -> String?
48
+ # @rbs return: bool -- true if logging succeeded
49
+ def self.error: (String message, **untyped fields) -> bool
50
50
 
51
51
  # @rbs message: String -- log message text
52
52
  # @rbs **fields: untyped -- additional key-value fields
53
- # @rbs return: String? -- formatted fatal log output
54
- def self.fatal: (String message, **untyped fields) -> String?
53
+ # @rbs return: bool -- true if logging succeeded
54
+ def self.fatal: (String message, **untyped fields) -> bool
55
55
  end
56
56
  end
data/sig/gum.rbs CHANGED
@@ -35,11 +35,11 @@ module Gum
35
35
 
36
36
  # Choose from a list of options
37
37
  # @see Gum::Choose#call
38
- def self.choose: (untyped items, **untyped) -> untyped
38
+ def self.choose: () -> untyped
39
39
 
40
40
  # Filter items with fuzzy matching
41
41
  # @see Gum::Filter#call
42
- def self.filter: (untyped items, **untyped) -> untyped
42
+ def self.filter: () -> untyped
43
43
 
44
44
  # Prompt for confirmation
45
45
  # @see Gum::Confirm#call
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: arm64-darwin
6
6
  authors:
7
7
  - Marco Roth