diff --git a/dup.rb b/dup.rb index 70146b0..b679e0f 100755 --- a/dup.rb +++ b/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 ]