aboutsummaryrefslogtreecommitdiffstats
path: root/lib/tasks/usage.rb
blob: d6aac454d2f450c01a6d6029f6e897f4dca40f4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
module Usage

    def usage_message message
        puts ''
        puts message
        puts ''
        exit 0
    end

    def check_for_env_vars(env_vars, example)
        missing = []
        env_vars.each do |env_var|
            unless ENV[env_var]
                missing << env_var
            end
        end
        if !missing.empty?
            usage = "Usage: This task requires #{env_vars.to_sentence} - missing #{missing.to_sentence}"
            if example
                usage += "\nExample: #{example}"
            end
            usage_message usage
        end
    end

end