Module: SnippetCli::VarBuilder

Extended by:
WizardHelpers::PromptHelpers
Defined in:
lib/snippet_cli/var_builder.rb,
lib/snippet_cli/var_builder/params.rb,
lib/snippet_cli/var_builder/form_fields.rb,
lib/snippet_cli/var_builder/param_schema.rb,
lib/snippet_cli/var_builder/name_collector.rb

Defined Under Namespace

Modules: FormFields, ParamSchema, Params

Constant Summary collapse

VAR_TYPES =
%w[echo shell date random choice script form clipboard].freeze
PROHIBITED_CHARS =

Characters that break variable-to-mapping resolution. Add more here as needed.

%w[-].freeze
SHELLS_BY_PLATFORM =
{
  macos: %w[sh bash pwsh nu],
  linux: %w[sh bash pwsh nu],
  windows: %w[cmd powershell pwsh wsl nu]
}.freeze

Class Method Summary collapse

Methods included from WizardHelpers::PromptHelpers

collect_search_terms, confirm!, list_confirm!, optional_prompt, prompt!

Class Method Details

.platform_shellsObject



33
34
35
36
37
38
39
# File 'lib/snippet_cli/var_builder.rb', line 33

def self.platform_shells
  case RUBY_PLATFORM
  when /darwin/             then SHELLS_BY_PLATFORM[:macos]
  when /mswin|mingw|cygwin/ then SHELLS_BY_PLATFORM[:windows]
  else SHELLS_BY_PLATFORM[:linux]
  end
end

.run(skip_initial_prompt: false) ⇒ Object

Collects Espanso variable definitions interactively. Raises WizardInterrupted on cancel. skip_initial_prompt: true skips “Add a variable?” and goes straight to collecting the first var. Returns { vars: Array, summary_clear: Proc }.



27
28
29
30
31
# File 'lib/snippet_cli/var_builder.rb', line 27

def self.run(skip_initial_prompt: false)
  interactive_session(skip_initial_prompt: skip_initial_prompt)
rescue Interrupt
  raise WizardInterrupted
end