mirror of
https://github.com/genebean/dots.git
synced 2026-03-27 09:27:44 -04:00
updated conditionals
This commit is contained in:
parent
e6cd38aa35
commit
7ea77f0740
1 changed files with 21 additions and 17 deletions
38
bin/dots.rb
38
bin/dots.rb
|
|
@ -28,35 +28,39 @@ else
|
||||||
abort("I'm not sure what to do with this OS...")
|
abort("I'm not sure what to do with this OS...")
|
||||||
end
|
end
|
||||||
|
|
||||||
@home = File.expand_path('~')
|
@home = File.expand_path('~')
|
||||||
@dotroot = File.dirname(File.dirname(File.expand_path($PROGRAM_NAME)))
|
@dotroot = File.dirname(File.dirname(File.expand_path($PROGRAM_NAME)))
|
||||||
|
@excludes = %w[mac nix]
|
||||||
|
|
||||||
task = prompt.select('What would you like to do?', %w[copy link])
|
task = prompt.select('What would you like to do?', %w[copy link])
|
||||||
case task
|
case task
|
||||||
when 'copy'
|
when 'copy'
|
||||||
files = Dir.glob("#{@dotroot}/copy/*")
|
files = Dir.glob("#{@dotroot}/copy/*")
|
||||||
|
|
||||||
puts 'The following symlinks will be made:'
|
if prompt.yes?('Are you sure you want to copy these files?')
|
||||||
files.each do |file|
|
puts 'Copying files...'
|
||||||
puts "#{@home}/.#{File.basename(file)} -> #{file}"
|
|
||||||
|
files.each do |file|
|
||||||
|
unless @excludes.include?(File.basename(file))
|
||||||
|
puts "Copying #{file} to #{@home}/.#{File.basename(file)}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
puts 'not copying'
|
||||||
end
|
end
|
||||||
|
|
||||||
if prompt.yes?('Shall we continue?')
|
|
||||||
puts 'yes'
|
|
||||||
else
|
|
||||||
puts 'no'
|
|
||||||
end
|
|
||||||
when 'link'
|
when 'link'
|
||||||
files = Dir.glob("#{@dotroot}/link/*")
|
files = Dir.glob("#{@dotroot}/link/*")
|
||||||
|
|
||||||
puts 'The following symlinks will be made:'
|
|
||||||
files.each do |file|
|
|
||||||
puts "#{@home}/.#{File.basename(file)} -> #{file}"
|
|
||||||
end
|
|
||||||
|
|
||||||
if prompt.yes?('Shall we continue?')
|
if prompt.yes?('Shall we continue?')
|
||||||
puts 'yes'
|
puts 'Creating symlinks...'
|
||||||
|
|
||||||
|
files.each do |file|
|
||||||
|
unless @excludes.include?(File.basename(file))
|
||||||
|
puts "Linking #{@home}/.#{File.basename(file)} to #{file}"
|
||||||
|
end
|
||||||
|
end
|
||||||
else
|
else
|
||||||
puts 'no'
|
puts 'no linking'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue