Class: Expressir::Cli
- Inherits:
-
Thor
- Object
- Thor
- Expressir::Cli
- Defined in:
- lib/expressir/cli.rb
Instance Method Summary collapse
- #format(path) ⇒ Object
-
#validate(*paths) ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/MethodLength.
- #version ⇒ Object
Instance Method Details
#format(path) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/expressir/cli.rb', line 6 def format(path) repository = Expressir::Express::Parser.from_file(path) repository.schemas.each do |schema| puts "\n(* Expressir formatted schema: #{schema.id} *)\n" puts schema.to_s(no_remarks: true) end end |
#validate(*paths) ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/MethodLength
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/expressir/cli.rb', line 36 def validate(*paths) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength no_version = [] no_valid = [] paths.each do |path| x = Pathname.new(path).realpath.relative_path_from(Dir.pwd) puts "Validating #{x}" ret = _validate_schema(path) if ret.nil? no_valid << "Failed to parse: #{x}" next end ret.each do |schema_id| no_version << "Missing version string: schema `#{schema_id}` | #{x}" end end _print_validation_errors(:failed_to_parse, no_valid) _print_validation_errors(:missing_version_string, no_version) exit 1 unless [no_valid, no_version].all?(&:empty?) puts "Validation passed for all EXPRESS schemas." end |