Class: Clack::Prompts::Path
- Inherits:
-
Core::Prompt
- Object
- Core::Prompt
- Clack::Prompts::Path
- Includes:
- Core::OptionsHelper, Core::TextInputHelper
- Defined in:
- lib/clack/prompts/path.rb
Overview
File/directory path selector with filesystem navigation.
Type to filter suggestions from the current directory. Press Tab to autocomplete the selected suggestion. Navigate suggestions with arrow keys.
Supports:
-
Absolute paths (starting with /)
-
Home directory expansion (~/…)
-
Relative paths (from root directory)
-
Directory-only filtering
Constant Summary
Constants inherited from Core::Prompt
Core::Prompt::MIN_TERMINAL_WIDTH
Instance Attribute Summary
Attributes inherited from Core::Prompt
#error_message, #state, #value, #warning_message
Instance Method Summary collapse
-
#initialize(message:, root: ".", only_directories: false, max_items: 5, **opts) ⇒ Path
constructor
A new instance of Path.
Methods included from Core::TextInputHelper
#current_placeholder, #format_placeholder_with_cursor, #input_display, #text_value, #text_value=, #value_with_cursor
Methods included from Core::OptionsHelper
#find_initial_cursor, #find_next_enabled, #first_enabled_index, #move_cursor, #move_selection, normalize_option, #normalize_options, #update_scroll, #visible_options
Methods inherited from Core::Prompt
flush_resize, register, #request_redraw, #run, setup_signal_handler, unregister
Constructor Details
#initialize(message:, root: ".", only_directories: false, max_items: 5, **opts) ⇒ Path
Returns a new instance of Path.
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/clack/prompts/path.rb', line 37 def initialize(message:, root: ".", only_directories: false, max_items: 5, **opts) super(message:, **opts) @root = File.(root) @only_directories = only_directories @max_items = max_items @value = "" @cursor = 0 @option_index = 0 @scroll_offset = 0 @suggestions = [] @dir_cache = {} # directory path => sorted entries array update_suggestions end |