feat: read version from shards.yml
This commit is contained in:
parent
5ad6018a88
commit
5d15886c27
5 changed files with 83 additions and 69 deletions
|
@ -8,3 +8,7 @@ shards:
|
|||
git: https://github.com/kanezoh/mechanize.cr.git
|
||||
version: 0.2.0
|
||||
|
||||
version_from_shard:
|
||||
git: https://github.com/hugopl/version_from_shard.git
|
||||
version: 1.2.5
|
||||
|
||||
|
|
|
@ -16,6 +16,8 @@ dependencies:
|
|||
mechanize:
|
||||
github: Kanezoh/mechanize.cr
|
||||
version: "~> 0.2.0"
|
||||
version_from_shard:
|
||||
github: hugopl/version_from_shard
|
||||
|
||||
# dependencies:
|
||||
# pg:
|
||||
|
|
66
src/cli.cr
Normal file
66
src/cli.cr
Normal file
|
@ -0,0 +1,66 @@
|
|||
require "./config"
|
||||
require "./version"
|
||||
require "./providers/signal_spam"
|
||||
|
||||
require "http/client"
|
||||
require "option_parser"
|
||||
require "file_utils"
|
||||
require "mechanize"
|
||||
|
||||
# Classe pour gérer les interactions avec Signal-Spam
|
||||
module BulkBarrage
|
||||
class Cli
|
||||
def initialize
|
||||
@option_parser = OptionParser.new do |parser|
|
||||
parser.banner = [
|
||||
"#{PROGRAM_NAME} v#{VERSION}",
|
||||
"Usage: bulkbarrage [options] [command] [args]"
|
||||
].join("\n")
|
||||
|
||||
parser.on("configure", "Initialize the configuration") do
|
||||
init_config
|
||||
end
|
||||
parser.on("report", "Process and report spam email (default: from STDIN)") do
|
||||
process_email_spam
|
||||
end
|
||||
parser.on("--help", "-h", "show this help") do
|
||||
puts parser
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def parse_arguments(args : Array(String))
|
||||
@option_parser.parse(args)
|
||||
rescue e : OptionParser::Exception
|
||||
puts e.message
|
||||
puts @option_parser
|
||||
exit(1)
|
||||
end
|
||||
|
||||
|
||||
private def init_config
|
||||
print "Enter username: "
|
||||
username = gets.try &.strip || "anonymous"
|
||||
print "Enter password: "
|
||||
password = gets.try &.strip || "anonymous"
|
||||
create_config_file(username, password)
|
||||
puts "Configuration file created."
|
||||
end
|
||||
|
||||
private def process_email_spam
|
||||
email_spam = STDIN.gets_to_end
|
||||
|
||||
signalspam = Providers::SignalSpam.new
|
||||
signalspam.process(email_spam)
|
||||
|
||||
puts "Email spam processed."
|
||||
end
|
||||
|
||||
private def create_config_file(username : String, password : String)
|
||||
signalspam = Providers::SignalSpam.new
|
||||
signalspam.create_config_file(username, password)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
69
src/main.cr
69
src/main.cr
|
@ -1,69 +1,4 @@
|
|||
require "./config"
|
||||
require "./providers/signal_spam"
|
||||
require "./cli"
|
||||
|
||||
require "http/client"
|
||||
require "option_parser"
|
||||
require "file_utils"
|
||||
require "mechanize"
|
||||
|
||||
# Nom du script et version
|
||||
SCRIPT_NAME = "BulkBarrage"
|
||||
SCRIPT_VERSION = "0.1.0"
|
||||
|
||||
# Classe pour gérer les interactions avec Signal-Spam
|
||||
class SignalSpamCtl
|
||||
def initialize
|
||||
@option_parser = OptionParser.new do |parser|
|
||||
parser.banner = [
|
||||
"#{SCRIPT_NAME} v#{SCRIPT_VERSION}",
|
||||
"Usage: bulkbarrage [options] [command] [args]"
|
||||
].join("\n")
|
||||
|
||||
parser.on("configure", "Initialise the configuration") do
|
||||
init_config
|
||||
end
|
||||
parser.on("report", "Process and report spam email (default: from STDIN)") do
|
||||
process_email_spam
|
||||
end
|
||||
parser.on("--help", "-h", "show this help") do
|
||||
puts parser
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def parse_arguments(args : Array(String))
|
||||
@option_parser.parse(args)
|
||||
rescue e : OptionParser::Exception
|
||||
puts e.message
|
||||
puts @option_parser
|
||||
exit(1)
|
||||
end
|
||||
|
||||
|
||||
private def init_config
|
||||
print "Enter username: "
|
||||
username = gets.try &.strip || "anonymous"
|
||||
print "Enter password: "
|
||||
password = gets.try &.strip || "anonymous"
|
||||
create_config_file(username, password)
|
||||
puts "Configuration file created."
|
||||
end
|
||||
|
||||
private def process_email_spam
|
||||
email_spam = STDIN.gets_to_end
|
||||
|
||||
signalspam = Providers::SignalSpam.new
|
||||
signalspam.process(email_spam)
|
||||
|
||||
puts "Email spam processed."
|
||||
end
|
||||
|
||||
private def create_config_file(username : String, password : String)
|
||||
signalspam = Providers::SignalSpam.new
|
||||
signalspam.create_config_file(username, password)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
client = SignalSpamCtl.new
|
||||
client = BulkBarrage::Cli.new
|
||||
client.parse_arguments(ARGV)
|
||||
|
|
|
@ -1,4 +1,11 @@
|
|||
|
||||
require "version_from_shard"
|
||||
|
||||
module BulkBarrage
|
||||
PROGRAM_NAME = "BulkBarrage"
|
||||
VersionFromShard.declare
|
||||
end
|
||||
|
||||
# Nom du script et version
|
||||
SCRIPT_NAME = "SignalSpamReporter"
|
||||
SCRIPT_VERSION = "1.2"
|
||||
# SCRIPT_NAME = "SignalSpamReporter"
|
||||
# SCRIPT_VERSION = "1.2"
|
||||
|
|
Loading…
Reference in a new issue