mirror of
https://github.com/genebean/dots.git
synced 2026-03-27 09:27:44 -04:00
Update repo structure as part of nixification
This commit is contained in:
parent
49e67c64fb
commit
cc0efcfdde
56 changed files with 181 additions and 154 deletions
82
bin/dots.rb
82
bin/dots.rb
|
|
@ -1,82 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'open3'
|
||||
require 'os'
|
||||
require 'tty-command'
|
||||
require 'tty-file'
|
||||
require 'tty-prompt'
|
||||
require_relative 'dotutils'
|
||||
|
||||
cmd = TTY::Command.new
|
||||
@prompt = TTY::Prompt.new(help_color: :magenta)
|
||||
|
||||
@home = File.expand_path('~')
|
||||
@dotroot = File.dirname(File.dirname(File.expand_path($PROGRAM_NAME)))
|
||||
@excludes = %w[linux mac nix ssh]
|
||||
@files_copy = Dir.glob("#{@dotroot}/copy/*")
|
||||
@files_link = Dir.glob("#{@dotroot}/link/*")
|
||||
@ssh_link = Dir.glob("#{@dotroot}/link/ssh/*")
|
||||
|
||||
if OS.posix?
|
||||
@files_copy.concat Dir.glob("#{@dotroot}/copy/nix/*")
|
||||
@files_link.concat Dir.glob("#{@dotroot}/link/nix/*")
|
||||
end
|
||||
|
||||
if OS.windows?
|
||||
puts 'It seems you are on Windows'
|
||||
|
||||
elsif OS.mac?
|
||||
mac_vers
|
||||
|
||||
@files_copy.concat Dir.glob("#{@dotroot}/copy/mac/*")
|
||||
@files_link.concat Dir.glob("#{@dotroot}/link/mac/*")
|
||||
|
||||
elsif OS.linux?
|
||||
@files_link.concat Dir.glob("#{@dotroot}/link/linux/*")
|
||||
|
||||
else
|
||||
abort("I'm not sure what to do with this OS...") unless OS.posix?
|
||||
end
|
||||
|
||||
task = @prompt.select('What would you like to do?', %w[copy link install exit])
|
||||
case task
|
||||
when 'copy'
|
||||
if @prompt.yes?('Are you sure you want to copy these files?')
|
||||
@files_copy.each do |file|
|
||||
unless @excludes.include?(File.basename(file))
|
||||
puts "Copying #{file} to #{@home}/.#{File.basename(file)}"
|
||||
copy_file(file, "#{@home}/.#{File.basename(file)}")
|
||||
end
|
||||
end
|
||||
else
|
||||
puts 'not copying'
|
||||
end
|
||||
|
||||
when 'link'
|
||||
if @prompt.yes?('Are you sure you want to link your dot files?')
|
||||
@files_link.each do |file|
|
||||
unless @excludes.include?(File.basename(file))
|
||||
# puts "Linking #{@home}/.#{File.basename(file)} to #{file}"
|
||||
link_file(file, "#{@home}/.#{File.basename(file)}")
|
||||
end
|
||||
end
|
||||
|
||||
# rubocop:disable Style/NumericLiteralPrefix
|
||||
Dir.mkdir("#{@home}/.ssh", 0700) unless File.directory?("#{@home}/.ssh")
|
||||
# rubocop:enable Style/NumericLiteralPrefix
|
||||
@ssh_link.each do |file|
|
||||
link_file(file, "#{@home}/.ssh/#{File.basename(file)}")
|
||||
end
|
||||
else
|
||||
puts 'not linking'
|
||||
end
|
||||
|
||||
when 'install'
|
||||
if @prompt.yes?('Are you sure you want to install your base packages?')
|
||||
cmd.run('bundle exec rake dots:run_puppet')
|
||||
cmd.run('bundle exec rake dots:vim_plugins')
|
||||
end
|
||||
|
||||
when 'exit'
|
||||
exit
|
||||
end # end of the case statement
|
||||
Loading…
Add table
Add a link
Reference in a new issue