43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
# File 'lib/sanguinews/config.rb', line 43
def parse_options!(args)
banner = []
banner << ""
banner << "sanguinews v#{Sanguinews::VERSION}. Copyright (c) 2013-2014 Tadeus Dobrovolskij."
banner << "Comes with ABSOLUTELY NO WARRANTY. Distributed under GPL v2 license(http://www.gnu.org/licenses/gpl-2.0.txt)."
banner << "sanguinews is a simple nntp(usenet) binary poster. It supports multithreading and SSL. More info in README."
banner << ""
opt_parser = OptionParser.new do |opt|
opt.banner = "Usage: sanguinews [OPTIONS] [DIRECTORY] | -f FILE1..[FILEX]"
opt.separator ""
opt.separator "Options"
opt.on("-c", "--config CONFIG", "use different config file") do |cfg|
@config = cfg
end
opt.on("-C", "--check", "check headers while uploading; slow but reliable") do
@data[:header_check] = true
end
opt.on("-f", "--file FILE", "upload FILE, treat all additional parameters as files") do |file|
@data[:filemode] = true
@data[:files] << file if File.file?(File.expand_path(file))
end
opt.on("-g", "--groups GROUP_LIST", "use these groups(comma separated) for upload") do |group_list|
@data[:groups] = group_list
end
opt.on("-h", "--help", "help") do
banner.each do |msg|
puts msg
end
puts opt_parser
puts
exit
end
opt.on("-p", "--password PASSWORD", "use PASSWORD as your password(overwrites config file)") do |password|
@data[:password] = password
end
opt.on("-r", "--recursive", "process all files under each directory recursively") do
@data[:recursive] = true
end
opt.on("-u", "--user USERNAME", "use USERNAME as your username(overwrites config file)") do |username|
@data[:username] = username
end
opt.on("-v", "--verbose", "be verbose?") do
@data[:verbose] = true
end
opt.on("-V", "--version", "print version information and then exit") do
puts Sanguinews::VERSION
exit
end
end
begin
opt_parser.parse!(args)
rescue OptionParser::InvalidOption, OptionParser::MissingArgument
puts opt_parser
exit 1
end
if !args.empty? && @data[:filemode]
args.each do |file|
next unless File.file?(File.expand_path(file))
@data[:files] << file.to_s
end
end
if @data[:files].empty?
if @data[:filemode] || args.empty?
puts "You need to specify something to upload!"
puts opt_parser
exit 1
else
args[0].end_with?('/') ? @data[:directory] = args[0] : @data[:directory] = args[0] + '/'
end
end
end
|