diff options
| author | mo khan <mo.khan@gmail.com> | 2019-12-27 16:25:28 -0700 |
|---|---|---|
| committer | mo khan <mo.khan@gmail.com> | 2019-12-27 16:25:28 -0700 |
| commit | b771f43fdac2a0d5b643c08387e7ca45166a34fe (patch) | |
| tree | 0500865905c9078f8abfa8e76866fc386952161b | |
| parent | 2d87d15728e45f7a7dc4ab4f2bab6881712644eb (diff) | |
Add scan command
| -rw-r--r-- | lib/spandx/cli.rb | 12 | ||||
| -rw-r--r-- | lib/spandx/commands/scan.rb | 18 | ||||
| -rw-r--r-- | lib/spandx/templates/scan/.gitkeep | 1 | ||||
| -rw-r--r-- | spec/integration/scan_spec.rb | 16 | ||||
| -rw-r--r-- | spec/unit/scan_spec.rb | 13 |
5 files changed, 60 insertions, 0 deletions
diff --git a/lib/spandx/cli.rb b/lib/spandx/cli.rb index 6bb3a7c..09608b3 100644 --- a/lib/spandx/cli.rb +++ b/lib/spandx/cli.rb @@ -17,5 +17,17 @@ module Spandx puts "v#{Spandx::VERSION}" end map %w[--version -v] => :version + + desc 'scan', 'Command description...' + method_option :help, aliases: '-h', type: :boolean, + desc: 'Display usage information' + def scan(*) + if options[:help] + invoke :help, ['scan'] + else + require_relative 'commands/scan' + Spandx::Commands::Scan.new(options).execute + end + end end end diff --git a/lib/spandx/commands/scan.rb b/lib/spandx/commands/scan.rb new file mode 100644 index 0000000..7b60c05 --- /dev/null +++ b/lib/spandx/commands/scan.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require_relative '../command' + +module Spandx + module Commands + class Scan < Spandx::Command + def initialize(options) + @options = options + end + + def execute(input: $stdin, output: $stdout) + # Command logic goes here ... + output.puts "OK" + end + end + end +end diff --git a/lib/spandx/templates/scan/.gitkeep b/lib/spandx/templates/scan/.gitkeep new file mode 100644 index 0000000..792d600 --- /dev/null +++ b/lib/spandx/templates/scan/.gitkeep @@ -0,0 +1 @@ +# diff --git a/spec/integration/scan_spec.rb b/spec/integration/scan_spec.rb new file mode 100644 index 0000000..678da1f --- /dev/null +++ b/spec/integration/scan_spec.rb @@ -0,0 +1,16 @@ +RSpec.describe "`spandx scan` command", type: :cli do + it "executes `spandx help scan` command successfully" do + output = `spandx help scan` + expected_output = <<-OUT +Usage: + spandx scan + +Options: + -h, [--help], [--no-help] # Display usage information + +Command description... + OUT + + expect(output).to eq(expected_output) + end +end diff --git a/spec/unit/scan_spec.rb b/spec/unit/scan_spec.rb new file mode 100644 index 0000000..812b765 --- /dev/null +++ b/spec/unit/scan_spec.rb @@ -0,0 +1,13 @@ +require 'spandx/commands/scan' + +RSpec.describe Spandx::Commands::Scan do + it "executes `scan` command successfully" do + output = StringIO.new + options = {} + command = Spandx::Commands::Scan.new(options) + + command.execute(output: output) + + expect(output.string).to eq("OK\n") + end +end |
