Class: Colours::Commandline

Inherits:
Base
  • Object
show all
Defined in:
lib/colours/commandline/commandline.rb

Overview

Colours::Commandline

Instance Method Summary collapse

Methods inherited from Base

#commandline_arguments?, #e, #extend_module_256_colours, #first_argument?, #second_argument?, #set_commandline_arguments

Constructor Details

#initialize(commandline_arguments = ARGV, run_already = true) ⇒ Commandline

#

initialize

#


21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/colours/commandline/commandline.rb', line 21

def initialize(
    commandline_arguments = ARGV,
    run_already          = true
  )
  set_commandline_arguments(
    commandline_arguments
  )
  # ======================================================================= #
  # Also store it on the toplevel since as of November 2023.
  # ======================================================================= #
  ::Colours.set_commandline_arguments(
    commandline_arguments
  )
  run if run_already
end

Instance Method Details

#

menu (menu tag)

#


40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/colours/commandline/commandline.rb', line 40

def menu(
    i = ARGV
  )
  if i.is_a? Array
    i.each {|entry| menu(entry) }
  else
    case i # case tag
    # ===================================================================== #
    # === colours --autogenerate_html_colours_methods
    # ===================================================================== #
    when /^-?-?autogenerate(-|_)?html(-|_)?colours(-|_)?methods$/i,
         /^-?-?autogenerate$/i
      ::Colours.autogenerate_html_colours_methods
    # ===================================================================== #
    # === colours --autogenerate_256_colours_methods
    # ===================================================================== #
    when /^-?-?autogenerate(-|_)?256(-|_)?colours(-|_)?methods$/i,
         /^-?-?256$/
      require 'colours/module_256_colours/module_256_colours.rb'
      ::Colours.autogenerate_256_colours_methods
    # ===================================================================== #
    # === colours --generate_shell_file_containing_the_html_colours
    #
    # This entry point will autogenerate the shell-file that contains
    # the HTML colours (RGB colours).
    # ===================================================================== #
    when /^-?-?generate(-|_)?shell(-|_)?file(-|_)?containing(-|_)?the(-|_)?html(-|_)?colours$/i,
         /^-?-?create(-|_)?shell(-|_)?file$/i # === colours --create-shell-file
      ::Colours.generate_shell_file_containing_the_html_colours
    # ===================================================================== #
    # === colours --show-html_colours
    # ===================================================================== #
    when /^-?-?show(-|_)?html(-|_)?colours$/i,
         /^-?-?show(-|_)?all(-|_)?html(-|_)?colours$/i,
         /^-?-?show(-|_)?all(-|_)?colours$/i,
         /^-?-?html(-|_)?colours$/i,
         'hcolours',
         'scolours',
         'all',
         'ALL',
         '1',
         'ALL_COLOURS',
         'colours?',
         'all_colours',
         'COLOURS',
         'html',
         '' # Show all colours here
      ::Colours.show_html_colours
      exit
    # ===================================================================== #
    # === colours --basics
    # ===================================================================== #
    when /^-?-?basics?$/i
      ::Colours.show_basic_colour_palette
      exit
    # ===================================================================== #
    # === colours --open
    # ===================================================================== #
    when /^-?-?open$/i
      open_this_file :then_exit
    # ===================================================================== #
    # === colours --file?
    # ===================================================================== #
    when /^-?-?file\??$/i
      cliner {
        e 'We will next read in from the default file, from:'
        e
        e "  #{sfile(TEST_FILE)}"
        e
        read_and_display_this_file
      }
    # ===================================================================== #
    # === colours --show-colour-palette
    # === colours --palette
    #
    # This entry point will show the basic colour palette.
    # ===================================================================== #
    when /^-?-?show(-|_)?colou?r(-|_)?palette$/i,
         /^-?-?show(-|_)?palette$/i,
         /^-?-?palette$/i
      show_colour_palette
    # ===================================================================== #
    # === colours --help
    # ===================================================================== #
    when /^-?-?help$/i
      show_help
    # ===================================================================== #
    # === colours --project_base_directory?
    # ===================================================================== #
    when /^-?-?project(_|-)?base(_|-)?dir\??$/i,
         /^-?-?project(_|-)?base(_|-)?directory\??$/i,
         /^-?-?base(_|-)?dir\??$/i
      e Colours.project_base_directory?
    # ===================================================================== #
    # === ruby commandline.rb --version
    # ===================================================================== #
    when /-?-?version/i
      Colours.show_the_version
    # ===================================================================== #
    # === colours --version
    #
    # Show the current version of the colours gem.
    # ===================================================================== #
    when /^-?-?versions?\??$/i
      show_the_version
    end
  end
end

#runObject

#

run (run tag)

#


159
160
161
# File 'lib/colours/commandline/commandline.rb', line 159

def run
  menu
end

#show_helpObject

#

show_help

#


152
153
154
# File 'lib/colours/commandline/commandline.rb', line 152

def show_help
  ::Colours.show_help
end