Method: Threatinator::CLI::Parser#_init_mod

Defined in:
lib/threatinator/cli/parser.rb

#_init_modObject



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/threatinator/cli/parser.rb', line 67

def _init_mod
  parser = self
  Module.new do
    extend Helpers
    extend GLI::App

    program_desc 'Threatinator!'

    add_cli_args(self, Threatinator::Config::FeedSearch.properties('feed_search'))

    desc "fetch and parse a feed"
    command :run do |c|
      c.flag 'run.coverage_output', type: String, desc: "Write coverage analysis to the specified file (CSV format)"

      add_cli_args(c, parser.run_action_config_class.properties('run'))
      c.action do |global_options, options, args|
        if options["run.feed_provider"].nil?
          options["run.feed_provider"] = args.shift
        end

        if options["run.feed_name"].nil?
          options["run.feed_name"] = args.shift
        end

        opts = fix_opts(global_options.merge(options))

        builder = Threatinator::CLI::RunActionBuilder.new(opts, args, parser.run_action_config_class)
        parser.builder = builder
      end
    end

    desc 'list out all the feeds'
    command :list do |c|
      add_cli_args(c, Threatinator::Actions::List::Config.properties('list'))
      c.action do |global_options, options, args|
        opts = fix_opts(global_options.merge(options))
        parser.builder = Threatinator::CLI::ListActionBuilder.new(opts, args)
      end
    end
  end
end