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