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.
- checksums.yaml +5 -5
- data/LICENSE.txt +1 -1
- data/README.md +435 -16
- data/exe/gum +11 -0
- data/gum.gemspec +28 -32
- data/lib/gum/command.rb +159 -0
- data/lib/gum/commands/choose.rb +95 -0
- data/lib/gum/commands/confirm.rb +57 -0
- data/lib/gum/commands/file.rb +84 -0
- data/lib/gum/commands/filter.rb +119 -0
- data/lib/gum/commands/format.rb +74 -0
- data/lib/gum/commands/input.rb +68 -0
- data/lib/gum/commands/join.rb +41 -0
- data/lib/gum/commands/log.rb +98 -0
- data/lib/gum/commands/pager.rb +55 -0
- data/lib/gum/commands/spin.rb +167 -0
- data/lib/gum/commands/style.rb +93 -0
- data/lib/gum/commands/table.rb +93 -0
- data/lib/gum/commands/write.rb +84 -0
- data/lib/gum/upstream.rb +17 -0
- data/lib/gum/version.rb +5 -1
- data/lib/gum.rb +170 -10
- data/sig/gum/command.rbs +23 -0
- data/sig/gum/commands/choose.rbs +42 -0
- data/sig/gum/commands/confirm.rbs +30 -0
- data/sig/gum/commands/file.rbs +38 -0
- data/sig/gum/commands/filter.rbs +48 -0
- data/sig/gum/commands/format.rbs +47 -0
- data/sig/gum/commands/input.rbs +32 -0
- data/sig/gum/commands/join.rbs +24 -0
- data/sig/gum/commands/log.rbs +56 -0
- data/sig/gum/commands/pager.rbs +28 -0
- data/sig/gum/commands/spin.rbs +55 -0
- data/sig/gum/commands/style.rbs +44 -0
- data/sig/gum/commands/table.rbs +35 -0
- data/sig/gum/commands/write.rbs +35 -0
- data/sig/gum/upstream.rbs +9 -0
- data/sig/gum/version.rbs +5 -0
- data/sig/gum.rbs +79 -0
- metadata +49 -145
- data/.gitignore +0 -9
- data/.rspec +0 -2
- data/.travis.yml +0 -5
- data/Gemfile +0 -4
- data/Rakefile +0 -6
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/gum-0.2.0.gem +0 -0
- data/lib/gum/factory.rb +0 -33
- data/lib/gum/filter.rb +0 -28
- data/lib/gum/filters/exists.rb +0 -25
- data/lib/gum/filters/fuzzy.rb +0 -11
- data/lib/gum/filters/geo/bbox.rb +0 -70
- data/lib/gum/filters/geo/distance.rb +0 -26
- data/lib/gum/filters/geo/range.rb +0 -33
- data/lib/gum/filters/geo.rb +0 -10
- data/lib/gum/filters/prefix.rb +0 -15
- data/lib/gum/filters/range.rb +0 -22
- data/lib/gum/filters/regexp.rb +0 -11
- data/lib/gum/filters/term.rb +0 -15
- data/lib/gum/filters/terms.rb +0 -11
- data/lib/gum/filters/wildcard.rb +0 -15
- data/lib/gum/filters.rb +0 -35
- data/lib/gum/order.rb +0 -18
- data/lib/gum/search.rb +0 -83
data/lib/gum.rb
CHANGED
|
@@ -1,14 +1,174 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
3
|
+
# rbs_inline: enabled
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
require 'active_support/core_ext/hash/compact'
|
|
6
|
-
require 'active_support/core_ext/object/try'
|
|
7
|
-
require 'active_support/inflector'
|
|
8
|
-
|
|
9
|
-
require 'gum/filter'
|
|
10
|
-
require 'gum/filters'
|
|
11
|
-
require 'gum/search'
|
|
5
|
+
require_relative "gum/version"
|
|
6
|
+
require_relative "gum/command"
|
|
12
7
|
|
|
13
8
|
module Gum
|
|
9
|
+
autoload :Upstream, "gum/upstream"
|
|
10
|
+
autoload :Choose, "gum/commands/choose"
|
|
11
|
+
autoload :Confirm, "gum/commands/confirm"
|
|
12
|
+
autoload :FilePicker, "gum/commands/file"
|
|
13
|
+
autoload :Filter, "gum/commands/filter"
|
|
14
|
+
autoload :Format, "gum/commands/format"
|
|
15
|
+
autoload :Input, "gum/commands/input"
|
|
16
|
+
autoload :Join, "gum/commands/join"
|
|
17
|
+
autoload :Log, "gum/commands/log"
|
|
18
|
+
autoload :Pager, "gum/commands/pager"
|
|
19
|
+
autoload :Spin, "gum/commands/spin"
|
|
20
|
+
autoload :Style, "gum/commands/style"
|
|
21
|
+
autoload :Table, "gum/commands/table"
|
|
22
|
+
autoload :Write, "gum/commands/write"
|
|
23
|
+
|
|
24
|
+
GEM_NAME = "gum"
|
|
25
|
+
DEFAULT_DIR = File.expand_path(File.join(__dir__, "..", "exe"))
|
|
26
|
+
|
|
27
|
+
class Error < StandardError; end
|
|
28
|
+
class ExecutableNotFoundException < Error; end
|
|
29
|
+
class UnsupportedPlatformException < Error; end
|
|
30
|
+
class DirectoryNotFoundException < Error; end
|
|
31
|
+
|
|
32
|
+
class << self
|
|
33
|
+
def execute(*args)
|
|
34
|
+
system(executable, *args.map(&:to_s))
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def platform
|
|
38
|
+
[:cpu, :os].map { |m| Gem::Platform.local.public_send(m) }.join("-")
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def version
|
|
42
|
+
"gum v#{VERSION} (upstream v#{Upstream::VERSION}) [#{platform}]"
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def executable(exe_path: DEFAULT_DIR)
|
|
46
|
+
gum_install_dir = ENV.fetch("GUM_INSTALL_DIR", nil)
|
|
47
|
+
|
|
48
|
+
if gum_install_dir
|
|
49
|
+
raise DirectoryNotFoundException, <<~MESSAGE unless File.directory?(gum_install_dir)
|
|
50
|
+
GUM_INSTALL_DIR is set to #{gum_install_dir}, but that directory does not exist.
|
|
51
|
+
MESSAGE
|
|
52
|
+
|
|
53
|
+
warn "NOTE: using GUM_INSTALL_DIR to find gum executable: #{gum_install_dir}"
|
|
54
|
+
exe_file = File.expand_path(File.join(gum_install_dir, "gum"))
|
|
55
|
+
else
|
|
56
|
+
if Gum::Upstream::NATIVE_PLATFORMS.keys.none? { |p| Gem::Platform.match_gem?(Gem::Platform.new(p), GEM_NAME) }
|
|
57
|
+
raise UnsupportedPlatformException, <<~MESSAGE
|
|
58
|
+
gum does not support the #{platform} platform.
|
|
59
|
+
Please install gum following instructions at https://github.com/charmbracelet/gum#installation
|
|
60
|
+
MESSAGE
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
exe_file = Dir.glob(File.expand_path(File.join(exe_path, "**", "gum"))).find do |f|
|
|
64
|
+
Gem::Platform.match_gem?(Gem::Platform.new(File.basename(File.dirname(f))), GEM_NAME)
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
if exe_file.nil? || !File.exist?(exe_file)
|
|
69
|
+
raise ExecutableNotFoundException, <<~MESSAGE
|
|
70
|
+
Cannot find the gum executable for #{platform} in #{exe_path}
|
|
71
|
+
|
|
72
|
+
If you're using bundler, please make sure you're on the latest bundler version:
|
|
73
|
+
|
|
74
|
+
gem install bundler
|
|
75
|
+
bundle update --bundler
|
|
76
|
+
|
|
77
|
+
Then make sure your lock file includes this platform by running:
|
|
78
|
+
|
|
79
|
+
bundle lock --add-platform #{platform}
|
|
80
|
+
bundle install
|
|
81
|
+
|
|
82
|
+
See `bundle lock --help` output for details.
|
|
83
|
+
|
|
84
|
+
If you're still seeing this message after taking those steps, try running
|
|
85
|
+
`bundle config` and ensure `force_ruby_platform` isn't set to `true`.
|
|
86
|
+
MESSAGE
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
exe_file
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# ─────────────────────────────────────────────────────────────────────────
|
|
93
|
+
# High-level Ruby API
|
|
94
|
+
# ─────────────────────────────────────────────────────────────────────────
|
|
95
|
+
|
|
96
|
+
# Prompt for single-line input
|
|
97
|
+
# @see Gum::Input#call
|
|
98
|
+
def input(**)
|
|
99
|
+
Input.call(**)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# Prompt for multi-line text input
|
|
103
|
+
# @see Gum::Write#call
|
|
104
|
+
def write(**)
|
|
105
|
+
Write.call(**)
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# Choose from a list of options
|
|
109
|
+
# @see Gum::Choose#call
|
|
110
|
+
def choose(...)
|
|
111
|
+
Choose.call(...)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# Filter items with fuzzy matching
|
|
115
|
+
# @see Gum::Filter#call
|
|
116
|
+
def filter(...)
|
|
117
|
+
Filter.call(...)
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
# Prompt for confirmation
|
|
121
|
+
# @see Gum::Confirm#call
|
|
122
|
+
def confirm(prompt = "Are you sure?", **)
|
|
123
|
+
Confirm.call(prompt, **)
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# Pick a file from the filesystem
|
|
127
|
+
# @see Gum::FilePicker#call
|
|
128
|
+
def file(path = nil, **)
|
|
129
|
+
FilePicker.call(path, **)
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
# Display content in a scrollable pager
|
|
133
|
+
# @see Gum::Pager#call
|
|
134
|
+
def pager(content, **)
|
|
135
|
+
Pager.call(content, **)
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
# Display a spinner while running a command or block
|
|
139
|
+
# @see Gum::Spin#call
|
|
140
|
+
def spin(title = "Loading...", **, &)
|
|
141
|
+
Spin.call(title, **, &)
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
# Apply styling to text
|
|
145
|
+
# @see Gum::Style#call
|
|
146
|
+
def style(*text, **)
|
|
147
|
+
Style.call(*text, **)
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
# Join text blocks together
|
|
151
|
+
# @see Gum::Join#call
|
|
152
|
+
def join(*texts, **)
|
|
153
|
+
Join.call(*texts, **)
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
# Format text (markdown, code, template, emoji)
|
|
157
|
+
# @see Gum::Format#call
|
|
158
|
+
def format(*text, **)
|
|
159
|
+
Format.call(*text, **)
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
# Display and select from tabular data
|
|
163
|
+
# @see Gum::Table#call
|
|
164
|
+
def table(data, **)
|
|
165
|
+
Table.call(data, **)
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
# Log a message
|
|
169
|
+
# @see Gum::Log#call
|
|
170
|
+
def log(message, **)
|
|
171
|
+
Log.call(message, **)
|
|
172
|
+
end
|
|
173
|
+
end
|
|
14
174
|
end
|
data/sig/gum/command.rbs
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Generated from lib/gum/command.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Gum
|
|
4
|
+
module Command
|
|
5
|
+
def self?.run: (*untyped, ?input: untyped, ?interactive: untyped) -> untyped
|
|
6
|
+
|
|
7
|
+
def self?.run_non_interactive: (*untyped args, input: untyped) -> untyped
|
|
8
|
+
|
|
9
|
+
def self?.run_interactive: (*untyped args) -> untyped
|
|
10
|
+
|
|
11
|
+
def self?.run_interactive_with_input: (*untyped args, input: untyped) -> untyped
|
|
12
|
+
|
|
13
|
+
def self?.run_display_only: (*untyped args, input: untyped) -> untyped
|
|
14
|
+
|
|
15
|
+
def self?.run_with_status: (*untyped args, ?input: untyped) -> untyped
|
|
16
|
+
|
|
17
|
+
def self?.build_args: (untyped command, *untyped positional, **untyped options) -> untyped
|
|
18
|
+
|
|
19
|
+
def self?.add_style_args: (untyped args, untyped flag, untyped style_hash) -> untyped
|
|
20
|
+
|
|
21
|
+
def self?.flag_supports_negation?: (untyped command, untyped flag) -> untyped
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Generated from lib/gum/commands/choose.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Gum
|
|
4
|
+
# Choose an option from a list of choices
|
|
5
|
+
#
|
|
6
|
+
# @example Single selection with array
|
|
7
|
+
# color = Gum.choose(%w[red green blue])
|
|
8
|
+
#
|
|
9
|
+
# @example Single selection with splat
|
|
10
|
+
# color = Gum.choose("red", "green", "blue")
|
|
11
|
+
#
|
|
12
|
+
# @example Multiple selection
|
|
13
|
+
# colors = Gum.choose(%w[red green blue], limit: 2)
|
|
14
|
+
#
|
|
15
|
+
# @example Unlimited selection
|
|
16
|
+
# colors = Gum.choose(%w[red green blue], no_limit: true)
|
|
17
|
+
#
|
|
18
|
+
# @example With header and custom height
|
|
19
|
+
# choice = Gum.choose(options, header: "Pick one:", height: 10)
|
|
20
|
+
class Choose
|
|
21
|
+
# Choose from a list of options
|
|
22
|
+
#
|
|
23
|
+
# @rbs *items: Array[String] | String -- list of choices to display (array or splat)
|
|
24
|
+
# @rbs limit: Integer? -- maximum number of items that can be selected (1 = single select)
|
|
25
|
+
# @rbs no_limit: bool -- allow unlimited selections (use tab/ctrl+space to select)
|
|
26
|
+
# @rbs ordered: bool? -- maintain selection order
|
|
27
|
+
# @rbs height: Integer? -- height of the list
|
|
28
|
+
# @rbs cursor: String? -- cursor character (default: ">")
|
|
29
|
+
# @rbs header: String? -- header text displayed above choices
|
|
30
|
+
# @rbs cursor_prefix: String? -- prefix for the cursor line
|
|
31
|
+
# @rbs selected_prefix: String? -- prefix for selected items (default: "✓")
|
|
32
|
+
# @rbs unselected_prefix: String? -- prefix for unselected items (default: "○")
|
|
33
|
+
# @rbs selected: Array[String]? -- items to pre-select
|
|
34
|
+
# @rbs timeout: Integer? -- timeout in seconds (0 = no timeout)
|
|
35
|
+
# @rbs cursor_style: Hash[Symbol, untyped]? -- cursor style options
|
|
36
|
+
# @rbs header_style: Hash[Symbol, untyped]? -- header text style
|
|
37
|
+
# @rbs item_style: Hash[Symbol, untyped]? -- item text style
|
|
38
|
+
# @rbs selected_style: Hash[Symbol, untyped]? -- selected item style
|
|
39
|
+
# @rbs return: String | Array[String] | nil -- selected item(s), or nil if cancelled
|
|
40
|
+
def self.call: (*Array[String] | String items, ?limit: Integer?, ?no_limit: bool, ?ordered: bool?, ?height: Integer?, ?cursor: String?, ?header: String?, ?cursor_prefix: String?, ?selected_prefix: String?, ?unselected_prefix: String?, ?selected: Array[String]?, ?timeout: Integer?, ?cursor_style: Hash[Symbol, untyped]?, ?header_style: Hash[Symbol, untyped]?, ?item_style: Hash[Symbol, untyped]?, ?selected_style: Hash[Symbol, untyped]?) -> (String | Array[String] | nil)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Generated from lib/gum/commands/confirm.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Gum
|
|
4
|
+
# Ask for user confirmation
|
|
5
|
+
#
|
|
6
|
+
# @example Basic confirmation
|
|
7
|
+
# if Gum.confirm("Delete file?")
|
|
8
|
+
# File.delete(path)
|
|
9
|
+
# end
|
|
10
|
+
#
|
|
11
|
+
# @example With default value
|
|
12
|
+
# proceed = Gum.confirm("Continue?", default: true)
|
|
13
|
+
#
|
|
14
|
+
# @example With custom button labels
|
|
15
|
+
# Gum.confirm("Save changes?", affirmative: "Save", negative: "Discard")
|
|
16
|
+
class Confirm
|
|
17
|
+
# Prompt for yes/no confirmation
|
|
18
|
+
#
|
|
19
|
+
# @rbs prompt: String -- the confirmation prompt
|
|
20
|
+
# @rbs default: bool? -- default value (true = yes, false = no)
|
|
21
|
+
# @rbs affirmative: String? -- text for affirmative button (default: "Yes")
|
|
22
|
+
# @rbs negative: String? -- text for negative button (default: "No")
|
|
23
|
+
# @rbs timeout: Integer? -- timeout in seconds (0 = no timeout)
|
|
24
|
+
# @rbs prompt_style: Hash[Symbol, untyped]? -- prompt text style options
|
|
25
|
+
# @rbs selected_style: Hash[Symbol, untyped]? -- selected button style options
|
|
26
|
+
# @rbs unselected_style: Hash[Symbol, untyped]? -- unselected button style options
|
|
27
|
+
# @rbs return: bool -- true if confirmed, false if rejected
|
|
28
|
+
def self.call: (?String prompt, ?default: bool?, ?affirmative: String?, ?negative: String?, ?timeout: Integer?, ?prompt_style: Hash[Symbol, untyped]?, ?selected_style: Hash[Symbol, untyped]?, ?unselected_style: Hash[Symbol, untyped]?) -> bool
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Generated from lib/gum/commands/file.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Gum
|
|
4
|
+
# Pick a file from a folder
|
|
5
|
+
#
|
|
6
|
+
# @example Basic file picker
|
|
7
|
+
# path = Gum.file
|
|
8
|
+
#
|
|
9
|
+
# @example Start from specific directory
|
|
10
|
+
# path = Gum.file(directory: "~/Documents")
|
|
11
|
+
#
|
|
12
|
+
# @example Show hidden files
|
|
13
|
+
# path = Gum.file(all: true)
|
|
14
|
+
#
|
|
15
|
+
# @example Only show directories
|
|
16
|
+
# dir = Gum.file(directory_only: true)
|
|
17
|
+
class FilePicker
|
|
18
|
+
# Pick a file from the filesystem
|
|
19
|
+
#
|
|
20
|
+
# @rbs path: String? -- starting directory path
|
|
21
|
+
# @rbs cursor: String? -- cursor character
|
|
22
|
+
# @rbs all: bool? -- show hidden files and directories
|
|
23
|
+
# @rbs file: bool? -- allow file selection (default: true)
|
|
24
|
+
# @rbs directory: bool? -- allow directory selection (default: false)
|
|
25
|
+
# @rbs directory_only: bool -- only allow directory selection (convenience option)
|
|
26
|
+
# @rbs height: Integer? -- height of the file picker
|
|
27
|
+
# @rbs timeout: Integer? -- timeout in seconds (0 = no timeout)
|
|
28
|
+
# @rbs cursor_style: Hash[Symbol, untyped]? -- cursor style options
|
|
29
|
+
# @rbs symlink_style: Hash[Symbol, untyped]? -- symlink text style
|
|
30
|
+
# @rbs directory_style: Hash[Symbol, untyped]? -- directory text style
|
|
31
|
+
# @rbs file_style: Hash[Symbol, untyped]? -- file text style
|
|
32
|
+
# @rbs permissions_style: Hash[Symbol, untyped]? -- permissions text style
|
|
33
|
+
# @rbs selected_style: Hash[Symbol, untyped]? -- selected item style
|
|
34
|
+
# @rbs file_size_style: Hash[Symbol, untyped]? -- file size text style
|
|
35
|
+
# @rbs return: String? -- selected file path, or nil if cancelled
|
|
36
|
+
def self.call: (?String? path, ?cursor: String?, ?all: bool?, ?file: bool?, ?directory: bool?, ?directory_only: bool, ?height: Integer?, ?timeout: Integer?, ?cursor_style: Hash[Symbol, untyped]?, ?symlink_style: Hash[Symbol, untyped]?, ?directory_style: Hash[Symbol, untyped]?, ?file_style: Hash[Symbol, untyped]?, ?permissions_style: Hash[Symbol, untyped]?, ?selected_style: Hash[Symbol, untyped]?, ?file_size_style: Hash[Symbol, untyped]?) -> String?
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Generated from lib/gum/commands/filter.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Gum
|
|
4
|
+
# Filter items from a list with fuzzy matching
|
|
5
|
+
#
|
|
6
|
+
# @example Single selection filter with array
|
|
7
|
+
# file = Gum.filter(Dir.glob("*"))
|
|
8
|
+
#
|
|
9
|
+
# @example Single selection filter with splat
|
|
10
|
+
# file = Gum.filter("file1.rb", "file2.rb", "file3.rb")
|
|
11
|
+
#
|
|
12
|
+
# @example Multiple selection filter
|
|
13
|
+
# files = Gum.filter(Dir.glob("*"), limit: 5)
|
|
14
|
+
#
|
|
15
|
+
# @example With placeholder and height
|
|
16
|
+
# selection = Gum.filter(items, placeholder: "Search...", height: 20)
|
|
17
|
+
class Filter
|
|
18
|
+
# Filter a list with fuzzy matching
|
|
19
|
+
#
|
|
20
|
+
# @rbs *items: Array[String] | String -- list of items to filter (array or splat)
|
|
21
|
+
# @rbs limit: Integer? -- maximum number of items that can be selected
|
|
22
|
+
# @rbs no_limit: bool -- allow unlimited selections (use tab/ctrl+space to select)
|
|
23
|
+
# @rbs height: Integer? -- height of the list
|
|
24
|
+
# @rbs width: Integer? -- width of the filter input
|
|
25
|
+
# @rbs placeholder: String? -- placeholder text for the filter input
|
|
26
|
+
# @rbs prompt: String? -- prompt string shown before input
|
|
27
|
+
# @rbs value: String? -- initial filter value
|
|
28
|
+
# @rbs header: String? -- header text displayed above the list
|
|
29
|
+
# @rbs indicator: String? -- character for selected item indicator
|
|
30
|
+
# @rbs selected_prefix: String? -- prefix for selected items
|
|
31
|
+
# @rbs unselected_prefix: String? -- prefix for unselected items
|
|
32
|
+
# @rbs match_prefix: String? -- prefix for matched text
|
|
33
|
+
# @rbs fuzzy: bool? -- enable fuzzy matching (default: true)
|
|
34
|
+
# @rbs sort: bool? -- sort results by match score (default: true)
|
|
35
|
+
# @rbs strict: bool? -- require exact match
|
|
36
|
+
# @rbs reverse: bool? -- reverse the order of results
|
|
37
|
+
# @rbs timeout: Integer? -- timeout in seconds (0 = no timeout)
|
|
38
|
+
# @rbs header_style: Hash[Symbol, untyped]? -- header text style
|
|
39
|
+
# @rbs text_style: Hash[Symbol, untyped]? -- text style for items
|
|
40
|
+
# @rbs cursor_text_style: Hash[Symbol, untyped]? -- style for cursor line text
|
|
41
|
+
# @rbs match_style: Hash[Symbol, untyped]? -- style for matched characters
|
|
42
|
+
# @rbs placeholder_style: Hash[Symbol, untyped]? -- placeholder text style
|
|
43
|
+
# @rbs prompt_style: Hash[Symbol, untyped]? -- prompt text style
|
|
44
|
+
# @rbs indicator_style: Hash[Symbol, untyped]? -- indicator character style
|
|
45
|
+
# @rbs return: String | Array[String] | nil -- selected item(s), or nil if cancelled
|
|
46
|
+
def self.call: (*Array[String] | String items, ?limit: Integer?, ?no_limit: bool, ?height: Integer?, ?width: Integer?, ?placeholder: String?, ?prompt: String?, ?value: String?, ?header: String?, ?indicator: String?, ?selected_prefix: String?, ?unselected_prefix: String?, ?match_prefix: String?, ?fuzzy: bool?, ?sort: bool?, ?strict: bool?, ?reverse: bool?, ?timeout: Integer?, ?header_style: Hash[Symbol, untyped]?, ?text_style: Hash[Symbol, untyped]?, ?cursor_text_style: Hash[Symbol, untyped]?, ?match_style: Hash[Symbol, untyped]?, ?placeholder_style: Hash[Symbol, untyped]?, ?prompt_style: Hash[Symbol, untyped]?, ?indicator_style: Hash[Symbol, untyped]?) -> (String | Array[String] | nil)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Generated from lib/gum/commands/format.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Gum
|
|
4
|
+
# Format text with markdown, code highlighting, templates, or emojis
|
|
5
|
+
#
|
|
6
|
+
# @example Markdown formatting
|
|
7
|
+
# Gum.format("# Hello\n- Item 1\n- Item 2")
|
|
8
|
+
#
|
|
9
|
+
# @example Code highlighting
|
|
10
|
+
# Gum.format(code, type: :code, language: "ruby")
|
|
11
|
+
#
|
|
12
|
+
# @example Template formatting
|
|
13
|
+
# Gum.format('{{ Bold "Hello" }} {{ Color "99" "0" " World " }}', type: :template)
|
|
14
|
+
#
|
|
15
|
+
# @example Emoji formatting
|
|
16
|
+
# Gum.format("I :heart: Ruby :gem:", type: :emoji)
|
|
17
|
+
class Format
|
|
18
|
+
TYPES: Array[Symbol]
|
|
19
|
+
|
|
20
|
+
# Format and render text
|
|
21
|
+
#
|
|
22
|
+
# @rbs *text: String -- text content to format (multiple strings joined with newlines)
|
|
23
|
+
# @rbs type: Symbol | String | nil -- format type (:markdown, :code, :template, :emoji)
|
|
24
|
+
# @rbs language: String? -- programming language for code highlighting
|
|
25
|
+
# @rbs theme: String? -- syntax highlighting theme
|
|
26
|
+
# @rbs return: String? -- formatted text output
|
|
27
|
+
def self.call: (*String text, ?type: Symbol | String | nil, ?language: String?, ?theme: String?) -> String?
|
|
28
|
+
|
|
29
|
+
# @rbs text: String -- markdown text to format
|
|
30
|
+
# @rbs return: String? -- rendered markdown output
|
|
31
|
+
def self.markdown: (String text) -> String?
|
|
32
|
+
|
|
33
|
+
# @rbs text: String -- source code to highlight
|
|
34
|
+
# @rbs language: String? -- programming language for highlighting
|
|
35
|
+
# @rbs theme: String? -- syntax highlighting theme
|
|
36
|
+
# @rbs return: String? -- syntax-highlighted code output
|
|
37
|
+
def self.code: (String text, ?language: String?, ?theme: String?) -> String?
|
|
38
|
+
|
|
39
|
+
# @rbs text: String -- template string with Termenv helpers
|
|
40
|
+
# @rbs return: String? -- rendered template output
|
|
41
|
+
def self.template: (String text) -> String?
|
|
42
|
+
|
|
43
|
+
# @rbs text: String -- text with :emoji_name: codes
|
|
44
|
+
# @rbs return: String? -- text with emojis rendered
|
|
45
|
+
def self.emoji: (String text) -> String?
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Generated from lib/gum/commands/input.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Gum
|
|
4
|
+
# Prompt for single-line input
|
|
5
|
+
#
|
|
6
|
+
# @example Basic input
|
|
7
|
+
# name = Gum.input(placeholder: "Enter your name")
|
|
8
|
+
#
|
|
9
|
+
# @example Password input
|
|
10
|
+
# password = Gum.input(password: true)
|
|
11
|
+
#
|
|
12
|
+
# @example With default value and custom prompt
|
|
13
|
+
# email = Gum.input(value: "user@", prompt: "> ", placeholder: "email")
|
|
14
|
+
class Input
|
|
15
|
+
# Prompt for single-line input
|
|
16
|
+
#
|
|
17
|
+
# @rbs placeholder: String? -- placeholder text shown when input is empty
|
|
18
|
+
# @rbs prompt: String? -- prompt string shown before input
|
|
19
|
+
# @rbs value: String? -- initial value for the input
|
|
20
|
+
# @rbs char_limit: Integer? -- maximum number of characters allowed
|
|
21
|
+
# @rbs width: Integer? -- width of the input field
|
|
22
|
+
# @rbs password: bool -- mask input characters for password entry
|
|
23
|
+
# @rbs header: String? -- header text displayed above the input
|
|
24
|
+
# @rbs timeout: Integer? -- timeout in seconds (0 = no timeout)
|
|
25
|
+
# @rbs cursor: Hash[Symbol, untyped]? -- cursor style options (foreground, background)
|
|
26
|
+
# @rbs prompt_style: Hash[Symbol, untyped]? -- prompt text style options
|
|
27
|
+
# @rbs placeholder_style: Hash[Symbol, untyped]? -- placeholder text style options
|
|
28
|
+
# @rbs header_style: Hash[Symbol, untyped]? -- header text style options
|
|
29
|
+
# @rbs return: String? -- the entered text, or nil if cancelled
|
|
30
|
+
def self.call: (?placeholder: String?, ?prompt: String?, ?value: String?, ?char_limit: Integer?, ?width: Integer?, ?password: bool, ?header: String?, ?timeout: Integer?, ?cursor: Hash[Symbol, untyped]?, ?prompt_style: Hash[Symbol, untyped]?, ?placeholder_style: Hash[Symbol, untyped]?, ?header_style: Hash[Symbol, untyped]?) -> String?
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Generated from lib/gum/commands/join.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Gum
|
|
4
|
+
# Join text blocks horizontally or vertically
|
|
5
|
+
#
|
|
6
|
+
# @example Horizontal join (default)
|
|
7
|
+
# combined = Gum.join(box1, box2)
|
|
8
|
+
#
|
|
9
|
+
# @example Vertical join
|
|
10
|
+
# stacked = Gum.join(box1, box2, vertical: true)
|
|
11
|
+
#
|
|
12
|
+
# @example With alignment
|
|
13
|
+
# aligned = Gum.join(box1, box2, vertical: true, align: :center)
|
|
14
|
+
class Join
|
|
15
|
+
# Join text blocks together
|
|
16
|
+
#
|
|
17
|
+
# @rbs *texts: String -- text blocks to join (usually styled with Gum.style)
|
|
18
|
+
# @rbs vertical: bool -- stack blocks vertically (default: false, horizontal)
|
|
19
|
+
# @rbs horizontal: bool -- place blocks side by side (default)
|
|
20
|
+
# @rbs align: Symbol | String | nil -- alignment (:left, :center, :right for vertical; :top, :middle, :bottom for horizontal)
|
|
21
|
+
# @rbs return: String? -- combined text output
|
|
22
|
+
def self.call: (*String texts, ?vertical: bool, ?horizontal: bool, ?align: Symbol | String | nil) -> String?
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Generated from lib/gum/commands/log.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Gum
|
|
4
|
+
# Log messages with different levels and formatting
|
|
5
|
+
#
|
|
6
|
+
# @example Basic logging
|
|
7
|
+
# Gum.log("Application started", level: :info)
|
|
8
|
+
#
|
|
9
|
+
# @example Structured logging with key-value pairs
|
|
10
|
+
# Gum.log("User created", level: :info, user_id: 123, email: "user@example.com")
|
|
11
|
+
#
|
|
12
|
+
# @example With timestamp
|
|
13
|
+
# Gum.log("Error occurred", level: :error, time: :rfc822)
|
|
14
|
+
class Log
|
|
15
|
+
LEVELS: Array[Symbol]
|
|
16
|
+
|
|
17
|
+
TIME_FORMATS: Array[Symbol]
|
|
18
|
+
|
|
19
|
+
# Log a message
|
|
20
|
+
#
|
|
21
|
+
# @rbs message: String -- log message text
|
|
22
|
+
# @rbs level: Symbol | String | nil -- log level (:debug, :info, :warn, :error, :fatal, :none)
|
|
23
|
+
# @rbs time: Symbol | String | nil -- time format (:rfc822, :rfc3339, :kitchen, etc.) or custom Go time format
|
|
24
|
+
# @rbs structured: bool? -- output structured log format (key=value pairs)
|
|
25
|
+
# @rbs formatter: Symbol | String | nil -- log formatter (:text, :json, :logfmt)
|
|
26
|
+
# @rbs prefix: String? -- log message prefix
|
|
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?
|
|
30
|
+
|
|
31
|
+
# @rbs message: String -- log message text
|
|
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?
|
|
35
|
+
|
|
36
|
+
# @rbs message: String -- log message text
|
|
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?
|
|
40
|
+
|
|
41
|
+
# @rbs message: String -- log message text
|
|
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?
|
|
45
|
+
|
|
46
|
+
# @rbs message: String -- log message text
|
|
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?
|
|
50
|
+
|
|
51
|
+
# @rbs message: String -- log message text
|
|
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?
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Generated from lib/gum/commands/pager.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Gum
|
|
4
|
+
# Scroll through content in a pager
|
|
5
|
+
#
|
|
6
|
+
# @example View file content
|
|
7
|
+
# Gum.pager(File.read("README.md"))
|
|
8
|
+
#
|
|
9
|
+
# @example With line numbers
|
|
10
|
+
# Gum.pager(content, show_line_numbers: true)
|
|
11
|
+
#
|
|
12
|
+
# @example Soft wrap long lines
|
|
13
|
+
# Gum.pager(content, soft_wrap: true)
|
|
14
|
+
class Pager
|
|
15
|
+
# Display content in a scrollable pager
|
|
16
|
+
#
|
|
17
|
+
# @rbs content: String -- content to display in the pager
|
|
18
|
+
# @rbs show_line_numbers: bool? -- display line numbers
|
|
19
|
+
# @rbs soft_wrap: bool? -- wrap long lines instead of horizontal scrolling
|
|
20
|
+
# @rbs timeout: Integer? -- timeout in seconds (0 = no timeout)
|
|
21
|
+
# @rbs help_style: Hash[Symbol, untyped]? -- help text style
|
|
22
|
+
# @rbs line_number_style: Hash[Symbol, untyped]? -- line number style
|
|
23
|
+
# @rbs match_style: Hash[Symbol, untyped]? -- search match style
|
|
24
|
+
# @rbs match_highlight_style: Hash[Symbol, untyped]? -- current search match highlight style
|
|
25
|
+
# @rbs return: void
|
|
26
|
+
def self.call: (String content, ?show_line_numbers: bool?, ?soft_wrap: bool?, ?timeout: Integer?, ?help_style: Hash[Symbol, untyped]?, ?line_number_style: Hash[Symbol, untyped]?, ?match_style: Hash[Symbol, untyped]?, ?match_highlight_style: Hash[Symbol, untyped]?) -> void
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Generated from lib/gum/commands/spin.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Gum
|
|
4
|
+
# Display a spinner while running a command or block
|
|
5
|
+
#
|
|
6
|
+
# @example With shell command
|
|
7
|
+
# Gum.spin("Installing...", command: "npm install")
|
|
8
|
+
#
|
|
9
|
+
# @example With Ruby block
|
|
10
|
+
# result = Gum.spin("Processing...") do
|
|
11
|
+
# # long running operation
|
|
12
|
+
# expensive_computation
|
|
13
|
+
# end
|
|
14
|
+
#
|
|
15
|
+
# @example Custom spinner type
|
|
16
|
+
# Gum.spin("Loading...", spinner: :dot, command: "sleep 5")
|
|
17
|
+
class Spin
|
|
18
|
+
SPINNERS: Array[Symbol]
|
|
19
|
+
|
|
20
|
+
# Display a spinner while running a command or block
|
|
21
|
+
#
|
|
22
|
+
# @rbs title: String -- spinner title text (default: "Loading...")
|
|
23
|
+
# @rbs command: String? -- shell command to execute
|
|
24
|
+
# @rbs spinner: Symbol | String | nil -- spinner type (see SPINNERS constant)
|
|
25
|
+
# @rbs show_output: bool? -- show command stdout after completion
|
|
26
|
+
# @rbs show_error: bool? -- show command stderr after completion
|
|
27
|
+
# @rbs align: Symbol? -- alignment of spinner and title (:left, :right)
|
|
28
|
+
# @rbs timeout: Integer? -- timeout in seconds (0 = no timeout)
|
|
29
|
+
# @rbs spinner_style: Hash[Symbol, untyped]? -- spinner animation style
|
|
30
|
+
# @rbs title_style: Hash[Symbol, untyped]? -- title text style
|
|
31
|
+
# @rbs &block: ^() -> untyped | nil -- Ruby block to execute (alternative to command)
|
|
32
|
+
# @rbs return: String | untyped | nil -- command output or block result, nil if cancelled
|
|
33
|
+
def self.call: (?String title, ?command: String?, ?spinner: Symbol | String | nil, ?show_output: bool?, ?show_error: bool?, ?align: Symbol?, ?timeout: Integer?, ?spinner_style: Hash[Symbol, untyped]?, ?title_style: Hash[Symbol, untyped]?) ?{ (?) -> untyped } -> (String | untyped | nil)
|
|
34
|
+
|
|
35
|
+
# @rbs title: String -- spinner title text
|
|
36
|
+
# @rbs command: String -- shell command to execute
|
|
37
|
+
# @rbs spinner: Symbol | String | nil -- spinner type
|
|
38
|
+
# @rbs show_output: bool? -- show command stdout
|
|
39
|
+
# @rbs show_error: bool? -- show command stderr
|
|
40
|
+
# @rbs align: Symbol? -- alignment of spinner
|
|
41
|
+
# @rbs timeout: Integer? -- timeout in seconds
|
|
42
|
+
# @rbs spinner_style: Hash[Symbol, untyped]? -- spinner animation style
|
|
43
|
+
# @rbs title_style: Hash[Symbol, untyped]? -- title text style
|
|
44
|
+
# @rbs return: bool? -- true if command succeeded, false/nil otherwise
|
|
45
|
+
def self.run_with_command: (String title, command: String, spinner: Symbol | String | nil, show_output: bool?, show_error: bool?, align: Symbol?, timeout: Integer?, spinner_style: Hash[Symbol, untyped]?, title_style: Hash[Symbol, untyped]?) -> bool?
|
|
46
|
+
|
|
47
|
+
# @rbs title: String -- spinner title text
|
|
48
|
+
# @rbs spinner: Symbol | String | nil -- spinner type
|
|
49
|
+
# @rbs spinner_style: Hash[Symbol, untyped]? -- spinner animation style
|
|
50
|
+
# @rbs title_style: Hash[Symbol, untyped]? -- title text style
|
|
51
|
+
# @rbs &block: ^() -> untyped -- Ruby block to execute
|
|
52
|
+
# @rbs return: untyped -- block result
|
|
53
|
+
def self.run_with_block: (String title, spinner: Symbol | String | nil, spinner_style: Hash[Symbol, untyped]?, title_style: Hash[Symbol, untyped]?) ?{ (?) -> untyped } -> untyped
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Generated from lib/gum/commands/style.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Gum
|
|
4
|
+
# Apply styling to text
|
|
5
|
+
#
|
|
6
|
+
# @example Basic styling
|
|
7
|
+
# styled = Gum.style("Hello", foreground: "212", bold: true)
|
|
8
|
+
#
|
|
9
|
+
# @example With border
|
|
10
|
+
# box = Gum.style("Content", border: :double, padding: "1 2")
|
|
11
|
+
#
|
|
12
|
+
# @example Multiple lines
|
|
13
|
+
# styled = Gum.style("Line 1", "Line 2", align: :center, width: 50)
|
|
14
|
+
class Style
|
|
15
|
+
BORDERS: Array[Symbol]
|
|
16
|
+
|
|
17
|
+
ALIGNMENTS: Array[Symbol]
|
|
18
|
+
|
|
19
|
+
# Apply styling to text
|
|
20
|
+
#
|
|
21
|
+
# @rbs *text: String -- text content to style (multiple strings become separate lines)
|
|
22
|
+
# @rbs foreground: String | Integer | nil -- text color (ANSI code, hex, or color name)
|
|
23
|
+
# @rbs background: String | Integer | nil -- background color (ANSI code, hex, or color name)
|
|
24
|
+
# @rbs border: Symbol | String | nil -- border style (:none, :hidden, :rounded, :double, :thick, :normal)
|
|
25
|
+
# @rbs border_foreground: String | Integer | nil -- border color
|
|
26
|
+
# @rbs border_background: String | Integer | nil -- border background color
|
|
27
|
+
# @rbs align: Symbol | String | nil -- text alignment (:left, :center, :right)
|
|
28
|
+
# @rbs height: Integer? -- fixed height in lines
|
|
29
|
+
# @rbs width: Integer? -- fixed width in characters
|
|
30
|
+
# @rbs margin: String | Array[Integer] | nil -- margin around the box ("1" or "1 2" or [1, 2, 1, 2])
|
|
31
|
+
# @rbs padding: String | Array[Integer] | nil -- padding inside the box ("1" or "1 2" or [1, 2, 1, 2])
|
|
32
|
+
# @rbs bold: bool? -- bold text
|
|
33
|
+
# @rbs italic: bool? -- italic text
|
|
34
|
+
# @rbs strikethrough: bool? -- strikethrough text
|
|
35
|
+
# @rbs underline: bool? -- underlined text
|
|
36
|
+
# @rbs faint: bool? -- faint/dim text
|
|
37
|
+
# @rbs return: String? -- styled text output
|
|
38
|
+
def self.call: (*String text, ?foreground: String | Integer | nil, ?background: String | Integer | nil, ?border: Symbol | String | nil, ?border_foreground: String | Integer | nil, ?border_background: String | Integer | nil, ?align: Symbol | String | nil, ?height: Integer?, ?width: Integer?, ?margin: String | Array[Integer] | nil, ?padding: String | Array[Integer] | nil, ?bold: bool?, ?italic: bool?, ?strikethrough: bool?, ?underline: bool?, ?faint: bool?) -> String?
|
|
39
|
+
|
|
40
|
+
# @rbs value: String | Integer | Array[Integer] | nil -- spacing value to format
|
|
41
|
+
# @rbs return: String? -- formatted spacing string
|
|
42
|
+
def self.format_spacing: (String | Integer | Array[Integer] | nil value) -> String?
|
|
43
|
+
end
|
|
44
|
+
end
|