Skip to content

Commit

Permalink
Move Cli::Opts definition moar to the top
Browse files Browse the repository at this point in the history
  • Loading branch information
Sija committed Oct 8, 2024
1 parent c1c597b commit d2c21be
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions src/ameba/cli/cmd.cr
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,26 @@ require "option_parser"
module Ameba::Cli
extend self

private class Opts
property config : Path?
property version : String?
property formatter : Symbol | String | Nil
property globs : Array(String)?
property only : Array(String)?
property except : Array(String)?
property describe_rule : String?
property location_to_explain : NamedTuple(file: String, line: Int32, column: Int32)?
property fail_level : Severity?
property stdin_filename : String?
property? skip_reading_config = false
property? rules = false
property? rule_versions = false
property? all = false
property? colors = true
property? without_affected_code = false
property? autocorrect = false
end

def run(args = ARGV)
opts = parse_args(args)

Expand Down Expand Up @@ -41,26 +61,6 @@ module Ameba::Cli
exit 255
end

private class Opts
property config : Path?
property version : String?
property formatter : Symbol | String | Nil
property globs : Array(String)?
property only : Array(String)?
property except : Array(String)?
property describe_rule : String?
property location_to_explain : NamedTuple(file: String, line: Int32, column: Int32)?
property fail_level : Severity?
property stdin_filename : String?
property? skip_reading_config = false
property? rules = false
property? rule_versions = false
property? all = false
property? colors = true
property? without_affected_code = false
property? autocorrect = false
end

def parse_args(args, opts = Opts.new)
OptionParser.parse(args) do |parser|
parser.banner = "Usage: ameba [options] [file1 file2 ...]"
Expand Down

0 comments on commit d2c21be

Please sign in to comment.