Class: GitJump::Actions::Setup
- Inherits:
-
Object
- Object
- GitJump::Actions::Setup
- Defined in:
- lib/git_jump/actions/setup.rb
Overview
Action to initialize/setup configuration file
Instance Attribute Summary collapse
-
#config_path ⇒ Object
readonly
Returns the value of attribute config_path.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(output:, config_path: nil, **_options) ⇒ Setup
constructor
A new instance of Setup.
Constructor Details
#initialize(output:, config_path: nil, **_options) ⇒ Setup
Returns a new instance of Setup.
9 10 11 12 |
# File 'lib/git_jump/actions/setup.rb', line 9 def initialize(output:, config_path: nil, **) @config_path = config_path || Utils::XDG.config_path @output = output end |
Instance Attribute Details
#config_path ⇒ Object (readonly)
Returns the value of attribute config_path.
7 8 9 |
# File 'lib/git_jump/actions/setup.rb', line 7 def config_path @config_path end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
7 8 9 |
# File 'lib/git_jump/actions/setup.rb', line 7 def output @output end |
Instance Method Details
#execute ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/git_jump/actions/setup.rb', line 14 def execute if File.exist?(@config_path) output.warning("Config file already exists at: #{@config_path}") return false unless output.prompt("Overwrite existing config?") end Utils::XDG.ensure_directories! File.write(@config_path, Config.default_config_content) output.success("Created config file at: #{@config_path}") output.info("Edit this file to customize your branch tracking settings") true rescue StandardError => e output.error("Failed to create config file: #{e.}") false end |