Class: Commiter::CommiterCli

Inherits:
Object
  • Object
show all
Defined in:
lib/commiter.rb

Class Method Summary collapse

Class Method Details



9
10
11
12
13
14
15
16
17
18
# File 'lib/commiter.rb', line 9

def self.print_help_messages(should_exit)
  puts "Command [-q] Generate Quick Git Messages Rules"
  puts "Command [-g] Generate Git Rules Based On Questions"
  puts "Command [-c] Generate Config File Without Change Git Rules"
  puts "Command [-d] Show Debug Messages While Generating Git Config"
  puts "Command [-r] Restore Git Rules Based On Config File"
  if should_exit
    exit
  end
end

.start_cliObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/commiter.rb', line 54

def self.start_cli
  cliParameters = ARGV
  should_show_debug_messages = false
  puts "########################### - Commiter Cli Starter -#################################"
  puts "Welcome To Commiter Version : #{Commiter::VERSION}"
  puts "This CLI Will Change Your Git Settings Commit Messages"
  puts "#####################################################################################"
  puts ""

  # Find Debug Option
  cliParameters.each do |item|
    if item == "-d"
      should_show_debug_messages = true
    end
  end

  if should_show_debug_messages
    puts "Commiter Arguments Validation Started ... With Input : #{cliParameters}"
  end

  # Start Validate CLI Params
  cliParameters.each do |item|
    self.validate_command_args(item, should_show_debug_messages)
  end

  puts ""
  # Start Generate If -g Found
  cliParameters.each do |item|
    if item == "-g"
      if should_show_debug_messages
        puts "Command [-g] Found Will Start The Generator ..."
      end
      CommiterGenerator::CommiterCliGenerator::start
    end
  end

end

.validate_command_args(option, should_show_debug_messages) ⇒ Object



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
51
52
# File 'lib/commiter.rb', line 20

def self.validate_command_args(option, should_show_debug_messages)
  case option
  when "-h"
    print_help_messages(true)
  when "-help"
    print_help_messages(true)
  when "--help"
    print_help_messages(true)
  when "-debug"
    @options[:verbose] = true
  when "-c"
    @options[:syntax_highlighting] = true
  when "-g"
    if should_show_debug_messages
      puts "Command [-g] Accepted Will Start Asking Questions Before Update Git Rules"
    end
  when "-q"
    if should_show_debug_messages
      puts "Command [-q] Accepted Generate Quick Git Messages Rules"
    end
  when "-c"
    if should_show_debug_messages
      puts "Command [-c] Accepted Generate Config File"
    end
  when "-d"
    if should_show_debug_messages
      puts "Command [-d] Accepted Will Show Debug Messages"
    end
  else
    puts "Command : [#{option} Rejected Use Cli -h To See The Supported Commands]"
  end

end