Class: Dmarcurator::Cli::App
- Inherits:
-
Object
- Object
- Dmarcurator::Cli::App
- Defined in:
- lib/dmarcurator/cli/app.rb
Instance Attribute Summary collapse
-
#db_uri ⇒ Object
readonly
Returns the value of attribute db_uri.
-
#reports_path ⇒ Object
readonly
Returns the value of attribute reports_path.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(db_path:, reports_path: nil) ⇒ App
constructor
A new instance of App.
- #run ⇒ Object
Constructor Details
#initialize(db_path:, reports_path: nil) ⇒ App
Returns a new instance of App.
53 54 55 56 |
# File 'lib/dmarcurator/cli/app.rb', line 53 def initialize(db_path:, reports_path: nil) @db_uri = "sqlite://#{File.(db_path)}" @reports_path = reports_path end |
Instance Attribute Details
#db_uri ⇒ Object (readonly)
Returns the value of attribute db_uri.
7 8 9 |
# File 'lib/dmarcurator/cli/app.rb', line 7 def db_uri @db_uri end |
#reports_path ⇒ Object (readonly)
Returns the value of attribute reports_path.
7 8 9 |
# File 'lib/dmarcurator/cli/app.rb', line 7 def reports_path @reports_path end |
Class Method Details
.main ⇒ Object
9 10 11 12 |
# File 'lib/dmarcurator/cli/app.rb', line 9 def self.main params = (ARGV) new(params).run end |
.parse_options(options) ⇒ Object
14 15 16 17 18 19 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 46 47 48 49 50 51 |
# File 'lib/dmarcurator/cli/app.rb', line 14 def self.() params = {} opt_parser = OptionParser.new do |parser| parser. = "dmarcurator parses DMARC reports and stores them into an SQLite3 DB.\nIt can also serve a basic web UI for viewing reports (-ui=true).\nUsage: dmarcurator [options]" parser.on("-db", "--db-sqlite=SQLITE_DB", "[Required] Path to sqlite3 DB. (e.g. ./tmp/reports.sqlite)") do |value| params[:db_path] = value end parser.on("-rp", "--reports-path=REPORTS_PATH", "Path to directory containing DMARC reports. (e.g. ./tmp/reports/)") do |value| params[:reports_path] = value end parser.on("-h", "--help", "Halp pls") do puts parser exit 0 end parser.on("-v", "--version", "Print version") do puts ::Dmarcurator::VERSION exit 0 end if .empty? puts parser exit 1 end end opt_parser.parse!() if !params[:reports_path] puts "Dmarcurator can import DMARC reports into an sqlite3 database -> Set --db and --reports-path)" exit 0 end params end |
Instance Method Details
#run ⇒ Object
58 59 60 61 62 |
# File 'lib/dmarcurator/cli/app.rb', line 58 def run if reports_path ::Dmarcurator::ImportReports.new(db_uri: db_uri, reports_path: reports_path).run end end |