mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
Raise error when passed invalid config file path
This commit is contained in:
parent
8c9d234d0b
commit
01a943d0d6
2 changed files with 10 additions and 2 deletions
|
@ -20,8 +20,14 @@ module Ameba::Cli
|
|||
|
||||
%w(-c --config).each do |f|
|
||||
it "accepts #{f} flag" do
|
||||
c = Cli.parse_args [f, "config.yml"]
|
||||
c.config.should eq Path["config.yml"]
|
||||
c = Cli.parse_args [f, "shard.yml"]
|
||||
c.config.should eq Path["shard.yml"]
|
||||
end
|
||||
|
||||
it "raises when config file doesn't exist" do
|
||||
expect_raises(ArgumentError, "Unable to find config file foo.yml") do
|
||||
Cli.parse_args [f, "foo.yml"]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -77,6 +77,8 @@ module Ameba::Cli
|
|||
|
||||
parser.on("-c", "--config PATH",
|
||||
"Specify a configuration file") do |path|
|
||||
raise ArgumentError.new("Unable to find config file #{path}") if !File.exists?(path) && !opts.skip_reading_config?
|
||||
|
||||
opts.config = Path[path] unless path.empty?
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue