Class: Crawlscope::Cli
- Inherits:
-
Object
- Object
- Crawlscope::Cli
- Defined in:
- lib/crawlscope/cli.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(argv, out:, err:, configuration: Configuration.new, task: nil) ⇒ Cli
constructor
A new instance of Cli.
Constructor Details
#initialize(argv, out:, err:, configuration: Configuration.new, task: nil) ⇒ Cli
Returns a new instance of Cli.
11 12 13 14 15 16 17 18 |
# File 'lib/crawlscope/cli.rb', line 11 def initialize(argv, out:, err:, configuration: Configuration.new, task: nil) @argv = Array(argv).dup @out = out @err = err @configuration = configuration @configuration.output = out @task = task end |
Class Method Details
.start(argv, out: $stdout, err: $stderr, **options) ⇒ Object
7 8 9 |
# File 'lib/crawlscope/cli.rb', line 7 def self.start(argv, out: $stdout, err: $stderr, **) new(argv, out: out, err: err, **).call end |
Instance Method Details
#call ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/crawlscope/cli.rb', line 20 def call command = @argv.shift.to_s case command when "help", "" @out.puts(general_usage) 0 when "validate" run_validate when "ldjson" run_ldjson when "version", "--version", "-v" @out.puts(Crawlscope::VERSION) 0 else @err.puts("Unknown command: #{command}") @err.puts("") @err.puts(general_usage) 1 end rescue OptionParser::InvalidOption, OptionParser::MissingArgument, ConfigurationError, ArgumentError => error @err.puts(error.) @err.puts("") @err.puts(general_usage) 1 end |