mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-03 11:25:29 -04:00
- add basic CLI
This commit is contained in:
parent
b4fcbf15ca
commit
2fe6506b2e
@ -20,8 +20,9 @@ class Config
|
||||
@[YAML::Field(key: "log_level")]
|
||||
property log_level : String = "info"
|
||||
|
||||
def self.load
|
||||
cfg_path = File.expand_path "~/.config/mango/config.yml", home: true
|
||||
def self.load(path : String?)
|
||||
path = "~/.config/mango/config.yml" if path.nil?
|
||||
cfg_path = File.expand_path path, home: true
|
||||
if File.exists? cfg_path
|
||||
return self.from_yaml File.read cfg_path
|
||||
end
|
||||
|
28
src/mango.cr
28
src/mango.cr
@ -1,11 +1,29 @@
|
||||
require "./server"
|
||||
require "./context"
|
||||
require "./config"
|
||||
require "./library"
|
||||
require "./storage"
|
||||
require "./logger"
|
||||
require "option_parser"
|
||||
|
||||
config = Config.load
|
||||
VERSION = "0.1.0"
|
||||
|
||||
config_path = nil
|
||||
|
||||
parser = OptionParser.parse do |parser|
|
||||
parser.banner = "Mango e-manga server/reader. Version #{VERSION}\n"
|
||||
|
||||
parser.on "-v", "--version", "Show version" do
|
||||
puts "Version #{VERSION}"
|
||||
exit
|
||||
end
|
||||
parser.on "-h", "--help", "Show help" do
|
||||
puts parser
|
||||
exit
|
||||
end
|
||||
parser.on "-c PATH", "--config=PATH", "Path to the config file. " \
|
||||
"Default is `~/.config/mango/config.yml`" do |path|
|
||||
config_path = path
|
||||
end
|
||||
end
|
||||
|
||||
config = Config.load config_path
|
||||
logger = MLogger.new config
|
||||
library = Library.new config.library_path, config.scan_interval, logger
|
||||
storage = Storage.new config.db_path, logger
|
||||
|
Loading…
x
Reference in New Issue
Block a user