mirror of
https://github.com/genebean/dots.git
synced 2026-03-27 09:27:44 -04:00
initial menu setup
This commit is contained in:
parent
1241ef7c85
commit
e6cd38aa35
3 changed files with 63 additions and 0 deletions
3
Gemfile
3
Gemfile
|
|
@ -23,6 +23,9 @@ group :development, :unit_tests do
|
|||
gem 'puppetlabs_spec_helper', '~> 1.1'
|
||||
gem 'rspec-puppet', '~> 2.5'
|
||||
gem 'rubocop', '~> 0.48'
|
||||
gem 'tty-command', '~> 0.4'
|
||||
gem 'tty-file', '~> 0.3'
|
||||
gem 'tty-prompt', '~> 0.12'
|
||||
gem 'yamllint', '~> 0.0.9'
|
||||
|
||||
# puppet-lint and plugins
|
||||
|
|
|
|||
22
Gemfile.lock
22
Gemfile.lock
|
|
@ -7,6 +7,7 @@ GEM
|
|||
cri (2.6.1)
|
||||
colored (~> 1.2)
|
||||
diff-lcs (1.3)
|
||||
equatable (0.5.0)
|
||||
facter (2.4.6)
|
||||
facter (2.4.6-universal-darwin)
|
||||
CFPropertyList (~> 2.2.6)
|
||||
|
|
@ -37,9 +38,13 @@ GEM
|
|||
metaclass (~> 0.0.1)
|
||||
multi_json (1.12.1)
|
||||
multipart-post (2.0.0)
|
||||
necromancer (0.4.0)
|
||||
os (1.0.0)
|
||||
parser (2.4.0.0)
|
||||
ast (~> 2.2)
|
||||
pastel (0.7.1)
|
||||
equatable (~> 0.5.0)
|
||||
tty-color (~> 0.4.0)
|
||||
powerpack (0.1.1)
|
||||
puppet (4.5.3)
|
||||
facter (> 2.0, < 4)
|
||||
|
|
@ -125,7 +130,21 @@ GEM
|
|||
spdx-licenses (1.1.0)
|
||||
text (1.3.1)
|
||||
trollop (2.1.2)
|
||||
tty-color (0.4.2)
|
||||
tty-command (0.4.0)
|
||||
pastel (~> 0.7.0)
|
||||
tty-cursor (0.4.0)
|
||||
tty-file (0.3.0)
|
||||
diff-lcs (~> 1.3.0)
|
||||
pastel (~> 0.7.0)
|
||||
tty-prompt (~> 0.12.0)
|
||||
tty-prompt (0.12.0)
|
||||
necromancer (~> 0.4.0)
|
||||
pastel (~> 0.7.0)
|
||||
tty-cursor (~> 0.4.0)
|
||||
wisper (~> 1.6.1)
|
||||
unicode-display_width (1.2.1)
|
||||
wisper (1.6.1)
|
||||
yamllint (0.0.9)
|
||||
trollop (~> 2)
|
||||
|
||||
|
|
@ -156,6 +175,9 @@ DEPENDENCIES
|
|||
rspec-puppet (~> 2.5)
|
||||
rubocop (~> 0.48)
|
||||
rugged (~> 0.24)
|
||||
tty-command (~> 0.4)
|
||||
tty-file (~> 0.3)
|
||||
tty-prompt (~> 0.12)
|
||||
yamllint (~> 0.0.9)
|
||||
|
||||
BUNDLED WITH
|
||||
|
|
|
|||
38
bin/dots.rb
38
bin/dots.rb
|
|
@ -1,5 +1,10 @@
|
|||
require 'open3'
|
||||
require 'os'
|
||||
require 'tty-command'
|
||||
require 'tty-file'
|
||||
require 'tty-prompt'
|
||||
|
||||
prompt = TTY::Prompt.new(help_color: :magenta)
|
||||
|
||||
if OS.mac?
|
||||
stdout, _stderr, _status = Open3.capture3('sw_vers -productVersion')
|
||||
|
|
@ -22,3 +27,36 @@ elsif OS.windows?
|
|||
else
|
||||
abort("I'm not sure what to do with this OS...")
|
||||
end
|
||||
|
||||
@home = File.expand_path('~')
|
||||
@dotroot = File.dirname(File.dirname(File.expand_path($PROGRAM_NAME)))
|
||||
|
||||
task = prompt.select('What would you like to do?', %w[copy link])
|
||||
case task
|
||||
when 'copy'
|
||||
files = Dir.glob("#{@dotroot}/copy/*")
|
||||
|
||||
puts 'The following symlinks will be made:'
|
||||
files.each do |file|
|
||||
puts "#{@home}/.#{File.basename(file)} -> #{file}"
|
||||
end
|
||||
|
||||
if prompt.yes?('Shall we continue?')
|
||||
puts 'yes'
|
||||
else
|
||||
puts 'no'
|
||||
end
|
||||
when '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?')
|
||||
puts 'yes'
|
||||
else
|
||||
puts 'no'
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue