gum 0.2.1 → 0.3.0

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.
Files changed (65) hide show
  1. checksums.yaml +5 -5
  2. data/LICENSE.txt +1 -1
  3. data/README.md +435 -16
  4. data/exe/gum +11 -0
  5. data/gum.gemspec +28 -32
  6. data/lib/gum/command.rb +159 -0
  7. data/lib/gum/commands/choose.rb +95 -0
  8. data/lib/gum/commands/confirm.rb +57 -0
  9. data/lib/gum/commands/file.rb +84 -0
  10. data/lib/gum/commands/filter.rb +119 -0
  11. data/lib/gum/commands/format.rb +74 -0
  12. data/lib/gum/commands/input.rb +68 -0
  13. data/lib/gum/commands/join.rb +41 -0
  14. data/lib/gum/commands/log.rb +98 -0
  15. data/lib/gum/commands/pager.rb +55 -0
  16. data/lib/gum/commands/spin.rb +167 -0
  17. data/lib/gum/commands/style.rb +93 -0
  18. data/lib/gum/commands/table.rb +93 -0
  19. data/lib/gum/commands/write.rb +84 -0
  20. data/lib/gum/upstream.rb +17 -0
  21. data/lib/gum/version.rb +5 -1
  22. data/lib/gum.rb +170 -10
  23. data/sig/gum/command.rbs +23 -0
  24. data/sig/gum/commands/choose.rbs +42 -0
  25. data/sig/gum/commands/confirm.rbs +30 -0
  26. data/sig/gum/commands/file.rbs +38 -0
  27. data/sig/gum/commands/filter.rbs +48 -0
  28. data/sig/gum/commands/format.rbs +47 -0
  29. data/sig/gum/commands/input.rbs +32 -0
  30. data/sig/gum/commands/join.rbs +24 -0
  31. data/sig/gum/commands/log.rbs +56 -0
  32. data/sig/gum/commands/pager.rbs +28 -0
  33. data/sig/gum/commands/spin.rbs +55 -0
  34. data/sig/gum/commands/style.rbs +44 -0
  35. data/sig/gum/commands/table.rbs +35 -0
  36. data/sig/gum/commands/write.rbs +35 -0
  37. data/sig/gum/upstream.rbs +9 -0
  38. data/sig/gum/version.rbs +5 -0
  39. data/sig/gum.rbs +79 -0
  40. metadata +49 -145
  41. data/.gitignore +0 -9
  42. data/.rspec +0 -2
  43. data/.travis.yml +0 -5
  44. data/Gemfile +0 -4
  45. data/Rakefile +0 -6
  46. data/bin/console +0 -14
  47. data/bin/setup +0 -8
  48. data/gum-0.2.0.gem +0 -0
  49. data/lib/gum/factory.rb +0 -33
  50. data/lib/gum/filter.rb +0 -28
  51. data/lib/gum/filters/exists.rb +0 -25
  52. data/lib/gum/filters/fuzzy.rb +0 -11
  53. data/lib/gum/filters/geo/bbox.rb +0 -70
  54. data/lib/gum/filters/geo/distance.rb +0 -26
  55. data/lib/gum/filters/geo/range.rb +0 -33
  56. data/lib/gum/filters/geo.rb +0 -10
  57. data/lib/gum/filters/prefix.rb +0 -15
  58. data/lib/gum/filters/range.rb +0 -22
  59. data/lib/gum/filters/regexp.rb +0 -11
  60. data/lib/gum/filters/term.rb +0 -15
  61. data/lib/gum/filters/terms.rb +0 -11
  62. data/lib/gum/filters/wildcard.rb +0 -15
  63. data/lib/gum/filters.rb +0 -35
  64. data/lib/gum/order.rb +0 -18
  65. data/lib/gum/search.rb +0 -83
@@ -0,0 +1,98 @@
1
+ # frozen_string_literal: true
2
+ # typed: true
3
+ # rbs_inline: enabled
4
+
5
+ module Gum
6
+ # Log messages with different levels and formatting
7
+ #
8
+ # @example Basic logging
9
+ # Gum.log("Application started", level: :info)
10
+ #
11
+ # @example Structured logging with key-value pairs
12
+ # Gum.log("User created", level: :info, user_id: 123, email: "user@example.com")
13
+ #
14
+ # @example With timestamp
15
+ # Gum.log("Error occurred", level: :error, time: :rfc822)
16
+ #
17
+ class Log
18
+ LEVELS = [:debug, :info, :warn, :error, :fatal, :none].freeze #: Array[Symbol]
19
+
20
+ TIME_FORMATS = [
21
+ :ansic, :unixdate, :rubydate, :rfc822, :rfc822z, :rfc850, :rfc1123, :rfc1123z, :rfc3339, :rfc3339nano, :kitchen
22
+ ].freeze #: Array[Symbol]
23
+
24
+ # Log a message
25
+ #
26
+ # @rbs message: String -- log message text
27
+ # @rbs level: Symbol | String | nil -- log level (:debug, :info, :warn, :error, :fatal, :none)
28
+ # @rbs time: Symbol | String | nil -- time format (:rfc822, :rfc3339, :kitchen, etc.) or custom Go time format
29
+ # @rbs structured: bool? -- output structured log format (key=value pairs)
30
+ # @rbs formatter: Symbol | String | nil -- log formatter (:text, :json, :logfmt)
31
+ # @rbs prefix: String? -- log message prefix
32
+ # @rbs **fields: untyped -- additional key-value fields for structured logging
33
+ # @rbs return: String? -- formatted log output
34
+ def self.call(
35
+ message,
36
+ level: nil,
37
+ time: nil,
38
+ structured: nil,
39
+ formatter: nil,
40
+ prefix: nil,
41
+ **fields
42
+ )
43
+ options = {
44
+ level: level&.to_s,
45
+ time: time&.to_s,
46
+ structured: structured,
47
+ formatter: formatter&.to_s,
48
+ prefix: prefix,
49
+ }
50
+
51
+ args = Command.build_args("log", **options.compact)
52
+
53
+ args << message
54
+
55
+ fields.each do |key, value|
56
+ args << key.to_s
57
+ args << value.to_s
58
+ end
59
+
60
+ Command.run(*args, interactive: false)
61
+ end
62
+
63
+ # @rbs message: String -- log message text
64
+ # @rbs **fields: untyped -- additional key-value fields
65
+ # @rbs return: String? -- formatted debug log output
66
+ def self.debug(message, **fields)
67
+ call(message, level: :debug, **fields)
68
+ end
69
+
70
+ # @rbs message: String -- log message text
71
+ # @rbs **fields: untyped -- additional key-value fields
72
+ # @rbs return: String? -- formatted info log output
73
+ def self.info(message, **fields)
74
+ call(message, level: :info, **fields)
75
+ end
76
+
77
+ # @rbs message: String -- log message text
78
+ # @rbs **fields: untyped -- additional key-value fields
79
+ # @rbs return: String? -- formatted warn log output
80
+ def self.warn(message, **fields)
81
+ call(message, level: :warn, **fields)
82
+ end
83
+
84
+ # @rbs message: String -- log message text
85
+ # @rbs **fields: untyped -- additional key-value fields
86
+ # @rbs return: String? -- formatted error log output
87
+ def self.error(message, **fields)
88
+ call(message, level: :error, **fields)
89
+ end
90
+
91
+ # @rbs message: String -- log message text
92
+ # @rbs **fields: untyped -- additional key-value fields
93
+ # @rbs return: String? -- formatted fatal log output
94
+ def self.fatal(message, **fields)
95
+ call(message, level: :fatal, **fields)
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+ # typed: true
3
+ # rbs_inline: enabled
4
+
5
+ module Gum
6
+ # Scroll through content in a pager
7
+ #
8
+ # @example View file content
9
+ # Gum.pager(File.read("README.md"))
10
+ #
11
+ # @example With line numbers
12
+ # Gum.pager(content, show_line_numbers: true)
13
+ #
14
+ # @example Soft wrap long lines
15
+ # Gum.pager(content, soft_wrap: true)
16
+ #
17
+ class Pager
18
+ # Display content in a scrollable pager
19
+ #
20
+ # @rbs content: String -- content to display in the pager
21
+ # @rbs show_line_numbers: bool? -- display line numbers
22
+ # @rbs soft_wrap: bool? -- wrap long lines instead of horizontal scrolling
23
+ # @rbs timeout: Integer? -- timeout in seconds (0 = no timeout)
24
+ # @rbs help_style: Hash[Symbol, untyped]? -- help text style
25
+ # @rbs line_number_style: Hash[Symbol, untyped]? -- line number style
26
+ # @rbs match_style: Hash[Symbol, untyped]? -- search match style
27
+ # @rbs match_highlight_style: Hash[Symbol, untyped]? -- current search match highlight style
28
+ # @rbs return: void
29
+ def self.call(
30
+ content,
31
+ show_line_numbers: nil,
32
+ soft_wrap: nil,
33
+ timeout: nil,
34
+ help_style: nil,
35
+ line_number_style: nil,
36
+ match_style: nil,
37
+ match_highlight_style: nil
38
+ )
39
+ options = {
40
+ "show-line-numbers": show_line_numbers,
41
+ "soft-wrap": soft_wrap,
42
+ timeout: timeout ? "#{timeout}s" : nil,
43
+ }
44
+
45
+ args = Command.build_args("pager", **options.compact)
46
+
47
+ Command.add_style_args(args, :help, help_style)
48
+ Command.add_style_args(args, :"line-number", line_number_style)
49
+ Command.add_style_args(args, :match, match_style)
50
+ Command.add_style_args(args, :"match-highlight", match_highlight_style)
51
+
52
+ Command.run_display_only(*args, input: content)
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,167 @@
1
+ # frozen_string_literal: true
2
+ # typed: true
3
+ # rbs_inline: enabled
4
+
5
+ require "shellwords"
6
+
7
+ module Gum
8
+ # Display a spinner while running a command or block
9
+ #
10
+ # @example With shell command
11
+ # Gum.spin("Installing...", command: "npm install")
12
+ #
13
+ # @example With Ruby block
14
+ # result = Gum.spin("Processing...") do
15
+ # # long running operation
16
+ # expensive_computation
17
+ # end
18
+ #
19
+ # @example Custom spinner type
20
+ # Gum.spin("Loading...", spinner: :dot, command: "sleep 5")
21
+ #
22
+ class Spin
23
+ SPINNERS = [
24
+ :line, :dot, :minidot, :jump, :pulse, :points, :globe, :moon, :monkey, :meter, :hamburger
25
+ ].freeze #: Array[Symbol]
26
+
27
+ # Display a spinner while running a command or block
28
+ #
29
+ # @rbs title: String -- spinner title text (default: "Loading...")
30
+ # @rbs command: String? -- shell command to execute
31
+ # @rbs spinner: Symbol | String | nil -- spinner type (see SPINNERS constant)
32
+ # @rbs show_output: bool? -- show command stdout after completion
33
+ # @rbs show_error: bool? -- show command stderr after completion
34
+ # @rbs align: Symbol? -- alignment of spinner and title (:left, :right)
35
+ # @rbs timeout: Integer? -- timeout in seconds (0 = no timeout)
36
+ # @rbs spinner_style: Hash[Symbol, untyped]? -- spinner animation style
37
+ # @rbs title_style: Hash[Symbol, untyped]? -- title text style
38
+ # @rbs &block: ^() -> untyped | nil -- Ruby block to execute (alternative to command)
39
+ # @rbs return: String | untyped | nil -- command output or block result, nil if cancelled
40
+ def self.call(
41
+ title = "Loading...",
42
+ command: nil,
43
+ spinner: nil,
44
+ show_output: nil,
45
+ show_error: nil,
46
+ align: nil,
47
+ timeout: nil,
48
+ spinner_style: nil,
49
+ title_style: nil,
50
+ &block
51
+ )
52
+ raise ArgumentError, "Cannot specify both command and block" if block && command
53
+
54
+ if block
55
+ run_with_block(title, spinner: spinner, spinner_style: spinner_style, title_style: title_style, &block)
56
+ else
57
+ run_with_command(
58
+ title,
59
+ command: command,
60
+ spinner: spinner,
61
+ show_output: show_output,
62
+ show_error: show_error,
63
+ align: align,
64
+ timeout: timeout,
65
+ spinner_style: spinner_style,
66
+ title_style: title_style
67
+ )
68
+ end
69
+ end
70
+
71
+ # @rbs title: String -- spinner title text
72
+ # @rbs command: String -- shell command to execute
73
+ # @rbs spinner: Symbol | String | nil -- spinner type
74
+ # @rbs show_output: bool? -- show command stdout
75
+ # @rbs show_error: bool? -- show command stderr
76
+ # @rbs align: Symbol? -- alignment of spinner
77
+ # @rbs timeout: Integer? -- timeout in seconds
78
+ # @rbs spinner_style: Hash[Symbol, untyped]? -- spinner animation style
79
+ # @rbs title_style: Hash[Symbol, untyped]? -- title text style
80
+ # @rbs return: bool? -- true if command succeeded, false/nil otherwise
81
+ def self.run_with_command(
82
+ title,
83
+ command:,
84
+ spinner:,
85
+ show_output:,
86
+ show_error:,
87
+ align:,
88
+ timeout:,
89
+ spinner_style:,
90
+ title_style:
91
+ )
92
+ raise ArgumentError, "Command is required when not using a block" unless command
93
+
94
+ options = {
95
+ title: title,
96
+ spinner: spinner&.to_s,
97
+ "show-output": show_output,
98
+ "show-error": show_error,
99
+ align: align&.to_s,
100
+ timeout: timeout ? "#{timeout}s" : nil,
101
+ }
102
+
103
+ args = Command.build_args("spin", **options.compact)
104
+
105
+ Command.add_style_args(args, :spinner, spinner_style)
106
+ Command.add_style_args(args, :title, title_style)
107
+
108
+ args << "--"
109
+ args.concat(command.shellsplit)
110
+
111
+ system(Gum.executable, *args.map(&:to_s))
112
+ end
113
+
114
+ # @rbs title: String -- spinner title text
115
+ # @rbs spinner: Symbol | String | nil -- spinner type
116
+ # @rbs spinner_style: Hash[Symbol, untyped]? -- spinner animation style
117
+ # @rbs title_style: Hash[Symbol, untyped]? -- title text style
118
+ # @rbs &block: ^() -> untyped -- Ruby block to execute
119
+ # @rbs return: untyped -- block result
120
+ def self.run_with_block(
121
+ title,
122
+ spinner:,
123
+ spinner_style:,
124
+ title_style:,
125
+ &block
126
+ )
127
+ require "fileutils"
128
+
129
+ result = nil
130
+ error = nil
131
+ marker_path = "/tmp/gum_spin_done_#{Process.pid}_#{Time.now.to_i}"
132
+
133
+ options = {
134
+ title: title,
135
+ spinner: spinner&.to_s,
136
+ }
137
+
138
+ args = Command.build_args("spin", **options.compact)
139
+
140
+ Command.add_style_args(args, :spinner, spinner_style)
141
+ Command.add_style_args(args, :title, title_style)
142
+
143
+ args << "--"
144
+ args.push("bash", "-c", "while [ ! -f #{marker_path} ]; do sleep 0.1; done")
145
+
146
+ spinner_pid = Process.fork do
147
+ exec(Gum.executable, *args.map(&:to_s))
148
+ end
149
+
150
+ begin
151
+ result = block.call
152
+ rescue StandardError => e
153
+ error = e
154
+ end
155
+
156
+ FileUtils.touch(marker_path)
157
+ Process.wait(spinner_pid)
158
+ FileUtils.rm_f(marker_path)
159
+
160
+ raise error if error
161
+
162
+ result
163
+ end
164
+
165
+ private_class_method :run_with_command, :run_with_block
166
+ end
167
+ end
@@ -0,0 +1,93 @@
1
+ # frozen_string_literal: true
2
+ # typed: true
3
+ # rbs_inline: enabled
4
+
5
+ module Gum
6
+ # Apply styling to text
7
+ #
8
+ # @example Basic styling
9
+ # styled = Gum.style("Hello", foreground: "212", bold: true)
10
+ #
11
+ # @example With border
12
+ # box = Gum.style("Content", border: :double, padding: "1 2")
13
+ #
14
+ # @example Multiple lines
15
+ # styled = Gum.style("Line 1", "Line 2", align: :center, width: 50)
16
+ #
17
+ class Style
18
+ BORDERS = [:none, :hidden, :rounded, :double, :thick, :normal].freeze #: Array[Symbol]
19
+ ALIGNMENTS = [:left, :center, :right, :top, :middle, :bottom].freeze #: Array[Symbol]
20
+
21
+ # Apply styling to text
22
+ #
23
+ # @rbs *text: String -- text content to style (multiple strings become separate lines)
24
+ # @rbs foreground: String | Integer | nil -- text color (ANSI code, hex, or color name)
25
+ # @rbs background: String | Integer | nil -- background color (ANSI code, hex, or color name)
26
+ # @rbs border: Symbol | String | nil -- border style (:none, :hidden, :rounded, :double, :thick, :normal)
27
+ # @rbs border_foreground: String | Integer | nil -- border color
28
+ # @rbs border_background: String | Integer | nil -- border background color
29
+ # @rbs align: Symbol | String | nil -- text alignment (:left, :center, :right)
30
+ # @rbs height: Integer? -- fixed height in lines
31
+ # @rbs width: Integer? -- fixed width in characters
32
+ # @rbs margin: String | Array[Integer] | nil -- margin around the box ("1" or "1 2" or [1, 2, 1, 2])
33
+ # @rbs padding: String | Array[Integer] | nil -- padding inside the box ("1" or "1 2" or [1, 2, 1, 2])
34
+ # @rbs bold: bool? -- bold text
35
+ # @rbs italic: bool? -- italic text
36
+ # @rbs strikethrough: bool? -- strikethrough text
37
+ # @rbs underline: bool? -- underlined text
38
+ # @rbs faint: bool? -- faint/dim text
39
+ # @rbs return: String? -- styled text output
40
+ def self.call(
41
+ *text,
42
+ foreground: nil,
43
+ background: nil,
44
+ border: nil,
45
+ border_foreground: nil,
46
+ border_background: nil,
47
+ align: nil,
48
+ height: nil,
49
+ width: nil,
50
+ margin: nil,
51
+ padding: nil,
52
+ bold: nil,
53
+ italic: nil,
54
+ strikethrough: nil,
55
+ underline: nil,
56
+ faint: nil
57
+ )
58
+ options = {
59
+ foreground: foreground&.to_s,
60
+ background: background&.to_s,
61
+ border: border&.to_s,
62
+ "border-foreground": border_foreground&.to_s,
63
+ "border-background": border_background&.to_s,
64
+ align: align&.to_s,
65
+ height: height,
66
+ width: width,
67
+ margin: format_spacing(margin),
68
+ padding: format_spacing(padding),
69
+ bold: bold,
70
+ italic: italic,
71
+ strikethrough: strikethrough,
72
+ underline: underline,
73
+ faint: faint,
74
+ }
75
+
76
+ args = Command.build_args("style", *text, **options.compact)
77
+ Command.run(*args, interactive: false)
78
+ end
79
+
80
+ # @rbs value: String | Integer | Array[Integer] | nil -- spacing value to format
81
+ # @rbs return: String? -- formatted spacing string
82
+ def self.format_spacing(value)
83
+ case value
84
+ when Array
85
+ value.join(" ")
86
+ when String, Integer
87
+ value.to_s
88
+ end
89
+ end
90
+
91
+ private_class_method :format_spacing
92
+ end
93
+ end
@@ -0,0 +1,93 @@
1
+ # frozen_string_literal: true
2
+ # typed: true
3
+ # rbs_inline: enabled
4
+
5
+ module Gum
6
+ # Display and select from tabular data
7
+ #
8
+ # @example From array of arrays
9
+ # selection = Gum.table([["Alice", 30], ["Bob", 25]], columns: %w[Name Age])
10
+ #
11
+ # @example From CSV string
12
+ # Gum.table(File.read("data.csv"))
13
+ #
14
+ # @example With custom separator
15
+ # Gum.table(data, separator: "\t")
16
+ #
17
+ class Table
18
+ # Display tabular data and optionally allow row selection
19
+ #
20
+ # @rbs data: String | Array[Array[untyped]] -- CSV string or array of row arrays
21
+ # @rbs columns: Array[String]? -- column headers (required when data is array)
22
+ # @rbs separator: String? -- column separator (default: ",")
23
+ # @rbs widths: Array[Integer]? -- column widths
24
+ # @rbs height: Integer? -- table height in rows
25
+ # @rbs print: bool? -- print table without selection (non-interactive)
26
+ # @rbs border: Symbol | String | nil -- border style (:rounded, :thick, :normal, :hidden, :double, :none)
27
+ # @rbs border_foreground: String | Integer | nil -- border color
28
+ # @rbs border_background: String | Integer | nil -- border background color
29
+ # @rbs cell_foreground: String | Integer | nil -- cell text color
30
+ # @rbs cell_background: String | Integer | nil -- cell background color
31
+ # @rbs header_foreground: String | Integer | nil -- header text color
32
+ # @rbs header_background: String | Integer | nil -- header background color
33
+ # @rbs selected_foreground: String | Integer | nil -- selected row text color
34
+ # @rbs selected_background: String | Integer | nil -- selected row background color
35
+ # @rbs return: String? -- selected row data, or nil if cancelled
36
+ def self.call(
37
+ data,
38
+ columns: nil,
39
+ separator: nil,
40
+ widths: nil,
41
+ height: nil,
42
+ print: nil,
43
+ border: nil,
44
+ border_foreground: nil,
45
+ border_background: nil,
46
+ cell_foreground: nil,
47
+ cell_background: nil,
48
+ header_foreground: nil,
49
+ header_background: nil,
50
+ selected_foreground: nil,
51
+ selected_background: nil
52
+ )
53
+ separator ||= ","
54
+
55
+ csv_data = if data.is_a?(Array)
56
+ rows = [] #: Array[String]
57
+ rows << columns.join(separator) if columns
58
+ rows.concat(data.map { |row| row.join(separator) })
59
+ rows.join("\n")
60
+ else
61
+ data.to_s
62
+ end
63
+
64
+ options = {
65
+ separator: separator,
66
+ widths: widths&.join(","),
67
+ height: height,
68
+ print: print,
69
+ border: border&.to_s,
70
+ "border.foreground": border_foreground&.to_s,
71
+ "border.background": border_background&.to_s,
72
+ "cell.foreground": cell_foreground&.to_s,
73
+ "cell.background": cell_background&.to_s,
74
+ "header.foreground": header_foreground&.to_s,
75
+ "header.background": header_background&.to_s,
76
+ "selected.foreground": selected_foreground&.to_s,
77
+ "selected.background": selected_background&.to_s,
78
+ }
79
+
80
+ args = Command.build_args("table", **options.compact)
81
+
82
+ if print
83
+ IO.popen([Gum.executable, *args.map(&:to_s)], "w") do |io|
84
+ io.write(csv_data)
85
+ end
86
+
87
+ nil
88
+ else
89
+ Command.run(*args, input: csv_data, interactive: true)
90
+ end
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,84 @@
1
+ # frozen_string_literal: true
2
+ # typed: true
3
+ # rbs_inline: enabled
4
+
5
+ module Gum
6
+ # Prompt for multi-line text input
7
+ #
8
+ # @example Basic multi-line input
9
+ # description = Gum.write(placeholder: "Enter description...")
10
+ #
11
+ # @example With dimensions
12
+ # notes = Gum.write(width: 80, height: 10, header: "Notes")
13
+ #
14
+ class Write
15
+ # Prompt for multi-line text input (Ctrl+D to submit)
16
+ #
17
+ # @rbs placeholder: String? -- placeholder text shown when empty
18
+ # @rbs prompt: String? -- prompt string shown at the start of each line
19
+ # @rbs value: String? -- initial value for the text area
20
+ # @rbs char_limit: Integer? -- maximum number of characters allowed
21
+ # @rbs width: Integer? -- width of the text area
22
+ # @rbs height: Integer? -- height of the text area in lines
23
+ # @rbs header: String? -- header text displayed above the input
24
+ # @rbs show_cursor_line: bool? -- highlight the line with the cursor
25
+ # @rbs show_line_numbers: bool? -- display line numbers
26
+ # @rbs timeout: Integer? -- timeout in seconds (0 = no timeout)
27
+ # @rbs cursor: Hash[Symbol, untyped]? -- cursor style options
28
+ # @rbs cursor_line: Hash[Symbol, untyped]? -- cursor line highlight style
29
+ # @rbs placeholder_style: Hash[Symbol, untyped]? -- placeholder text style
30
+ # @rbs prompt_style: Hash[Symbol, untyped]? -- prompt text style
31
+ # @rbs end_of_buffer: Hash[Symbol, untyped]? -- end of buffer character style
32
+ # @rbs line_number: Hash[Symbol, untyped]? -- line number style
33
+ # @rbs header_style: Hash[Symbol, untyped]? -- header text style
34
+ # @rbs base: Hash[Symbol, untyped]? -- base text style
35
+ # @rbs return: String? -- the entered text, or nil if cancelled
36
+ def self.call(
37
+ placeholder: nil,
38
+ prompt: nil,
39
+ value: nil,
40
+ char_limit: nil,
41
+ width: nil,
42
+ height: nil,
43
+ header: nil,
44
+ show_cursor_line: nil,
45
+ show_line_numbers: nil,
46
+ timeout: nil,
47
+ cursor: nil,
48
+ cursor_line: nil,
49
+ placeholder_style: nil,
50
+ prompt_style: nil,
51
+ end_of_buffer: nil,
52
+ line_number: nil,
53
+ header_style: nil,
54
+ base: nil
55
+ )
56
+ options = {
57
+ placeholder: placeholder,
58
+ prompt: prompt,
59
+ value: value,
60
+ char_limit: char_limit,
61
+ width: width,
62
+ height: height,
63
+ header: header,
64
+ show_cursor_line: show_cursor_line,
65
+ show_line_numbers: show_line_numbers,
66
+ timeout: timeout ? "#{timeout}s" : nil,
67
+ base: base,
68
+ }
69
+
70
+ options[:cursor] = cursor if cursor
71
+ options[:cursor_line] = cursor_line if cursor_line
72
+ options[:end_of_buffer] = end_of_buffer if end_of_buffer
73
+ options[:line_number] = line_number if line_number
74
+
75
+ args = Command.build_args("write", **options.compact)
76
+
77
+ Command.add_style_args(args, :placeholder, placeholder_style)
78
+ Command.add_style_args(args, :prompt, prompt_style)
79
+ Command.add_style_args(args, :header, header_style)
80
+
81
+ Command.run(*args)
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+ # typed: true
3
+ # rbs_inline: enabled
4
+
5
+ module Gum
6
+ module Upstream
7
+ VERSION = "0.17.0"
8
+
9
+ NATIVE_PLATFORMS = {
10
+ "arm64-darwin" => "gum_#{VERSION}_Darwin_arm64.tar.gz",
11
+ "x86_64-darwin" => "gum_#{VERSION}_Darwin_x86_64.tar.gz",
12
+ "arm64-linux" => "gum_#{VERSION}_Linux_arm64.tar.gz",
13
+ "aarch64-linux" => "gum_#{VERSION}_Linux_arm64.tar.gz",
14
+ "x86_64-linux" => "gum_#{VERSION}_Linux_x86_64.tar.gz",
15
+ }.freeze
16
+ end
17
+ end
data/lib/gum/version.rb CHANGED
@@ -1,3 +1,7 @@
1
+ # frozen_string_literal: true
2
+ # typed: true
3
+ # rbs_inline: enabled
4
+
1
5
  module Gum
2
- VERSION = '0.2.1'.freeze
6
+ VERSION = "0.3.0"
3
7
  end