Skip to content

Commit

Permalink
Add command line --set option, but no handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kelsey Judson committed Oct 18, 2012
1 parent e5306ff commit 80f5183
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
22 changes: 17 additions & 5 deletions bin/dotfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Dotfile::Options
options.update_file = nil
options.edit = false
options.edit_file = nil
options.set = nil
options.edit_config = false
options.edit_local = false
options.edit_groups = false
Expand All @@ -37,6 +38,15 @@ class Dotfile::Options
options.edit_file = file
end

opts.on('-s', '--set OPTION:VALUE', "Temporarily set an option value.") do |o|
arg = o.split(':')
if arg.length == 2
options.set = { option: arg[0], value: arg[1] }
else
abort "Usage: dotfile --set OPTION:VALUE"
end
end

opts.on('-c', '--edit-config', "Edit dotfile.conf.") do
options.edit_config = true
end
Expand All @@ -49,7 +59,7 @@ class Dotfile::Options
options.edit_groups = true
end

opts.on('-s', '--setup', "Prepare the local environment.") do
opts.on('-S', '--setup', "Prepare the local environment.") do
options.setup = true
end

Expand All @@ -58,13 +68,15 @@ class Dotfile::Options
end

opts.on_tail('-v', '--version', "Show version number.") do
abort "dotfile v#{Dotfile::VERSION}\n\n" +
" Copyright (C) 2012 Kelsey David Judson\n" +
" Web: http://github.com/kelseyjudson/dotfile"
puts "dotfile v#{Dotfile::VERSION}\n\n" +
" Copyright (C) 2012 Kelsey David Judson\n" +
" Web: http://github.com/kelseyjudson/dotfile"
exit
end

opts.on_tail('-h', '--help', "Show help.") do
abort opts.help
puts opts.help
exit
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/dotfile/dotfile_cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def update
else
puts "Running Full Update",
"---------------------",
# Check for existence of dotfile.conf
# Check for existence of dotfile.conf.
check_configuration
# Load the configuration.
load_configuration_all
Expand Down
3 changes: 2 additions & 1 deletion lib/dotfile/dotfile_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ module Dotfile

class Configuration

attr_reader :settings, :groups, :static_files, :templates
attr_reader :groups, :static_files, :templates
attr_accessor :settings

def initialize(options = { load_dotfiles: true })
@settings = Dotfile::Settings.new
Expand Down

0 comments on commit 80f5183

Please sign in to comment.