mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
parent
248c5a656b
commit
d60aea102f
3 changed files with 18 additions and 2 deletions
|
@ -57,6 +57,16 @@ module Ameba::Cli
|
|||
c.formatter.should eq :todo
|
||||
end
|
||||
|
||||
it "accepts --no-color flag" do
|
||||
c = Cli.parse_args %w(--no-color)
|
||||
c.colors?.should be_false
|
||||
end
|
||||
|
||||
it "doesn't disable colors by default" do
|
||||
c = Cli.parse_args %w(--all)
|
||||
c.colors?.should be_true
|
||||
end
|
||||
|
||||
it "ignores --config if --gen-config flag passed" do
|
||||
c = Cli.parse_args %w(--gen-config --config my_config.yml)
|
||||
c.formatter.should eq :todo
|
||||
|
|
|
@ -7,7 +7,7 @@ module Ameba::Cli
|
|||
|
||||
def run(args)
|
||||
opts = parse_args args
|
||||
config = Config.load opts.config
|
||||
config = Config.load opts.config, opts.colors?
|
||||
config.files = opts.files
|
||||
|
||||
configure_formatter(config, opts)
|
||||
|
@ -26,6 +26,7 @@ module Ameba::Cli
|
|||
property only : Array(String)?
|
||||
property except : Array(String)?
|
||||
property? all = false
|
||||
property? colors = true
|
||||
end
|
||||
|
||||
def parse_args(args, opts = Opts.new)
|
||||
|
@ -66,6 +67,10 @@ module Ameba::Cli
|
|||
opts.formatter = :todo
|
||||
opts.config = ""
|
||||
end
|
||||
|
||||
parser.on("--no-color", "Disable colors") do
|
||||
opts.colors = false
|
||||
end
|
||||
end
|
||||
|
||||
opts
|
||||
|
|
|
@ -46,7 +46,8 @@ class Ameba::Config
|
|||
# config = Ameba::Config.load
|
||||
# ```
|
||||
#
|
||||
def self.load(path = PATH)
|
||||
def self.load(path = PATH, colors? = true)
|
||||
Colorize.enabled = colors?
|
||||
content = File.exists?(path) ? File.read path : ""
|
||||
Config.new YAML.parse(content)
|
||||
rescue e
|
||||
|
|
Loading…
Reference in a new issue