class Dotfiler::CLI::Commands::Install

Constants

BACKUP_DIR
TIMESTAMP_FORMAT

Public Instance Methods

call(path: , **options) click to toggle source
# File lib/dotfiler/cli/commands/install.rb, line 14
def call(path: , **options)
  handle_errors do
    dotfiles_path = to_path.(path)

    validate_dotfiles_file!(dotfiles_path)

    configure_dotfiles_dir(dotfiles_path)

    config.reload!
    dotfiles.config.reload!
    dotfiles.reload!

    create_symlinks
  end
end

Private Instance Methods

backup(path) click to toggle source
# File lib/dotfiler/cli/commands/install.rb, line 53
def backup(path)
  fs.create_dir(backup_dir_path.to_s) unless backup_dir_path.exists?
  info("Backing up #{path} to #{backup_dir_path}...")
  mover.call(path, backup_dir_path)
end
backup_dir_path() click to toggle source
# File lib/dotfiler/cli/commands/install.rb, line 59
def backup_dir_path
  @_backup_dir_path ||= config.home_path.join("#{BACKUP_DIR}_#{current_timestamp}")
end
configure_dotfiles_dir(dotfiles_path) click to toggle source
# File lib/dotfiler/cli/commands/install.rb, line 40
def configure_dotfiles_dir(dotfiles_path)
  config.update!(dotfiles: dotfiles_path.to_s)
end
current_timestamp() click to toggle source
# File lib/dotfiler/cli/commands/install.rb, line 63
def current_timestamp
  Time.now.strftime(TIMESTAMP_FORMAT)
end
validate_dotfiles_file!(dotfiles_path) click to toggle source
# File lib/dotfiler/cli/commands/install.rb, line 32
def validate_dotfiles_file!(dotfiles_path)
  dotfiles_path = dotfiles_path.join(config.dotfiles_file_name)

  return if dotfiles_path.file?

  error!("Dotfiles file (#{dotfiles_path}) not found...")
end