File tree Expand file tree Collapse file tree 5 files changed +59
-0
lines changed Expand file tree Collapse file tree 5 files changed +59
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ def self.runner
1010
1111 runner . route 'init' , to : Commands ::Init
1212 runner . route 'preview' , to : Commands ::Preview
13+ runner . route 'validate' , to : Commands ::Validate
1314 runner . route 'generate' , to : Commands ::Generate
1415 runner . route 'add' , to : Commands ::Add
1516
Original file line number Diff line number Diff line change 1+ module Bashly
2+ module Commands
3+ class Validate < Base
4+ help "Scan the configuration file for errors"
5+
6+ usage "bashly validate"
7+ usage "bashly validate (-h|--help)"
8+
9+ environment "BASHLY_SOURCE_DIR" , "The path containing the bashly configuration and source files [default: src]"
10+
11+ def run
12+ config = Config . new "#{ Settings . source_dir } /bashly.yml"
13+ validator = ConfigValidator . new config
14+ validator . validate
15+ say "!txtgrn!OK"
16+ end
17+ end
18+ end
19+ end
Original file line number Diff line number Diff line change @@ -3,5 +3,6 @@ Bashly - Bash CLI Generator
33Commands:
44 init Initialize a new workspace
55 preview Generate the bash script to STDOUT
6+ validate Scan the configuration file for errors
67 generate Generate the bash script and required files
78 add Add extra features and customization to your script
Original file line number Diff line number Diff line change 1+ Scan the configuration file for errors
2+
3+ Usage:
4+ bashly validate
5+ bashly validate (-h|--help)
6+
7+ Options:
8+ -h --help
9+ Show this help
10+
11+ Environment Variables:
12+ BASHLY_SOURCE_DIR
13+ The path containing the bashly configuration and source files [default: src]
Original file line number Diff line number Diff line change 1+ require 'spec_helper'
2+
3+ describe Commands ::Validate do
4+ let ( :source_dir ) { Settings . source_dir }
5+ subject { CLI . runner }
6+
7+ context "with --help" do
8+ it "shows long usage" do
9+ expect { subject . run %w[ validate --help ] } . to output_approval ( 'cli/validate/help' )
10+ end
11+ end
12+
13+ context "without arguments" do
14+ before do
15+ reset_tmp_dir
16+ success = system "mkdir -p #{ source_dir } && cp lib/bashly/templates/bashly.yml #{ source_dir } /bashly.yml"
17+ expect ( success ) . to be true
18+ end
19+
20+ it "validates the script" do
21+ expect { subject . run %w[ validate ] } . to output ( "OK\n " ) . to_stdout
22+ end
23+ end
24+
25+ end
You can’t perform that action at this time.
0 commit comments