Only require base_dir and container for certain commands.
This commit is contained in:
parent
7a83662485
commit
648da782d4
17
dup.rb
17
dup.rb
@ -167,6 +167,8 @@ action = :run
|
||||
container = nil
|
||||
$dry_run = false
|
||||
$pull = false
|
||||
needs_container = true
|
||||
needs_basedir = true
|
||||
|
||||
opts = GetoptLong.new(
|
||||
[ '--sample', '-s', GetoptLong::NO_ARGUMENT ],
|
||||
@ -182,6 +184,7 @@ opts.each do |opt, arg|
|
||||
action_sample
|
||||
when '--create'
|
||||
action = :create
|
||||
needs_basedir = true
|
||||
when '--help'
|
||||
action_help
|
||||
when '--dry-run'
|
||||
@ -194,15 +197,17 @@ end
|
||||
|
||||
container = ARGV.shift
|
||||
|
||||
if container==nil || container==""
|
||||
if needs_container && (container==nil || container=="")
|
||||
raise "No container given."
|
||||
end
|
||||
|
||||
if ENV['DUP_DIR']
|
||||
base_dir = ENV['DUP_DIR']
|
||||
else
|
||||
base_dir = File.join(Dir.home, ".dup")
|
||||
puts "Environment variable DUP_DIR is not set. Looking for .yml files in #{base_dir}"
|
||||
if needs_basedir
|
||||
if ENV['DUP_DIR']
|
||||
base_dir = ENV['DUP_DIR']
|
||||
else
|
||||
base_dir = File.join(Dir.home, ".dup")
|
||||
puts "Environment variable DUP_DIR is not set. Looking for .yml files in #{base_dir}"
|
||||
end
|
||||
end
|
||||
|
||||
file = "%s/%s.yml" % [ base_dir, container ]
|
||||
|
Loading…
Reference in New Issue
Block a user