Skip to content

Commit

Permalink
Merge branch 'Hiyorimi-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdstaaij committed May 22, 2016
2 parents 2c179df + f57d5d2 commit 231e222
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/cli_parser.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'optparse'

Options = Struct.new(:cfgfile, :kill_tg)
Options = Struct.new(:cfgfile, :kill_tg, :userdir, :backlog_limit)

class CliParser
def self.parse(options)
Expand All @@ -22,6 +22,15 @@ def self.parse(options)
puts opts
exit
end

opts.on("-dDIR", "--dir=DIR", String, "Subdirectory for logs") do |userdir|
args.userdir = userdir
end

opts.on("-lLIMIT", "--limit=LIMIT", Integer, "Maximum number of messages to backup for each target (0 means unlimited)") do |backlog_limit|
args.backlog_limit = backlog_limit
end

end

opt_parser.parse!(options)
Expand Down
12 changes: 12 additions & 0 deletions telegram-history-dump.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,18 @@ def save_progress

FileUtils.mkdir_p(get_backup_dir)

if !cli_opts[:userdir].nil?
if !cli_opts.userdir.empty? || !cli_opts.userdir.nil?
$config['backup_dir'] = File.join($config['backup_dir'],cli_opts.userdir)
end
end

if !cli_opts[:backlog_limit].nil?
if !cli_opts.backlog_limit.empty? || !cli_opts.backlog_limit.nil?
$config['backlog_limit'] = cli_opts.backlog_limit
end
end

$dumper = JsonDumper.new
$progress = {}
$progress_snapshot = {}
Expand Down

0 comments on commit 231e222

Please sign in to comment.