Skip to content

Commit

Permalink
Allow config to be missing.
Browse files Browse the repository at this point in the history
  • Loading branch information
Manfred committed Mar 2, 2021
1 parent 44ca0ea commit f071af6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/teletube/cli.cr
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module Teletube
if context.errors.any?
print_errors
elsif context.run?
@context.filename = argv.last
@context.filename = argv.empty? ? nil : argv.last
run_command
end
end
Expand Down
6 changes: 5 additions & 1 deletion src/teletube/config.cr
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ module Teletube
end

def self.load(path = PATH)
Config.new(YAML.parse(File.exists?(path) ? File.read(path) : "{}"))
if File.exists?(path)
Config.new(YAML.parse(File.read(path)))
else
Config.new
end
rescue e
raise "Config file is invalid: #{e.message}"
end
Expand Down

0 comments on commit f071af6

Please sign in to comment.