Skip to content

Commit

Permalink
Add --rcfile (-R) option
Browse files Browse the repository at this point in the history
TODO: Connect option to RCFile class to set custom file path. (#19)
  • Loading branch information
sferik committed Apr 13, 2012
1 parent e03e965 commit e232229
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/twurl/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def parse_options(args)
quiet
disable_ssl
request_method
rcfile
help
version
end
Expand Down Expand Up @@ -232,6 +233,12 @@ def request_method
end
end

def rcfile
on('-R', '--rcfile [path]', 'Path to RC file (default: ~/.twurlrc)') do |rcfile|
options.rcfile = rcfile
end
end

def help
on_tail("-h", "--help", "Show this message") do
CLI.puts self
Expand Down
13 changes: 13 additions & 0 deletions test/cli_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,17 @@ def test_setting_host_updates_to_requested_value
end
end
include HostOptionTests

module RCFileTests
def test_setting_rcfile_uses_custom_rcfile
custom_rcfile = '/tmp/rcfile'
assert Twurl::RCFile.file_path != custom_rcfile

[['-R', custom_rcfile], ['--rcfile', custom_rcfile]].each do |option_combination|
options = Twurl::CLI.parse_options(option_combination)
assert_equal custom_rcfile, options.rcfile
end
end
end
include RCFileTests
end

0 comments on commit e232229

Please sign in to comment.