Class: FPM::Scriptable::Util

Inherits:
Object
  • Object
show all
Defined in:
lib/fpm/scriptable/util.rb

Class Method Summary collapse

Class Method Details



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/fpm/scriptable/util.rb', line 71

def self.banner
  c = FPM::Scriptable::Constants.instance
  banner = <<EOF

   __                                     _       _        _     _
  / _|_ __  _ __ ___        ___  ___ _ __(_)_ __ | |_ __ _| |__ | | ___
 | |_| '_ \\| '_ ` _ \\ _____/ __|/ __| '__| | '_ \\| __/ _` | '_ \\| |/ _ \\
 |  _| |_) | | | | | |_____\\__ \\ (__| |  | | |_) | || (_| | |_) | |  __/
 |_| | .__/|_| |_| |_|     |___/\\___|_|  |_| .__/ \\__\\__,_|_.__/|_|\\___|
     |_|                                   |_|

 #{c.name}
 Version: #{c.version}
 Author:  #{c.author}
 Website: #{c.website}

EOF
  banner
end

.get_argsObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/fpm/scriptable/util.rb', line 19

def self.get_args
  args = Hash.new
  cur_argv = String.new

  if ARGV.length > 0
    ARGV.each do |x|
      if x =~ /^-/
        cur_argv = x.sub(/^-+/,'')
        if cur_argv != ''
          args[cur_argv.to_sym] = ''
        end
      else
        if cur_argv != ''
          if args[cur_argv.to_sym].instance_of? Array
            args[cur_argv.to_sym].push x
          else
            if args[cur_argv.to_sym] != ''
              cur_value = args[cur_argv.to_sym]
              args[cur_argv.to_sym] = Array.new
              args[cur_argv.to_sym].push cur_value
              args[cur_argv.to_sym].push x
            else
              args[cur_argv.to_sym] = x
            end
          end

        end
      end
    end
  end
  args
end

.usageObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/fpm/scriptable/util.rb', line 52

def self.usage
  usage = <<EOF
Usage:
  #{$0} OPTIONS

  Options:
    --help                  Display this help screen
    --quiet                 Messages are not displayed to the console
    --nocolor               Turn off colors in console output
    --log_level <lvl>       Log level (info, debug, error)
    --logfile <file>        Log to file
    --nobanner              Do not show the banner

    --script <file>         Script to build

EOF
  usage
end