1 # This file is part of NIT ( http://www.nitlanguage.org ).
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
16 module nitsmell_toolcontext
23 redef class ToolContext
26 var opt_all
= new OptionBool("Print all code smells for top 10 class", "--all")
28 var opt_get_all
= new OptionBool("Print all code smells for all class", "--get-all")
30 var opt_feature_envy
= new OptionBool("Print feature envy", "--feature-envy")
32 var opt_large_class
= new OptionBool("Print large class", "--large-class")
34 var opt_long_method
= new OptionBool("Print long method", "--long-methods")
35 # --no-abstract-implementation
36 var opt_no_abstract_implementation
= new OptionBool("Print the no implemented abstract method", "--no-abstract-implementation")
38 var opt_long_params
= new OptionBool("Print long parameters", "--long-params")
40 var opt_move_generics
= new OptionBool("Print the move proposition for generic class", "--move-generics")
42 var opt_long_method_threshold
= new OptionInt("Select long method threshold", 0 ,"--long-method-threshold")
43 # --long-method-threshold
44 var opt_long_params_threshold
= new OptionInt("Select long method parameters threshold", 0 ,"--long-params-threshold")
45 # --long-params-threshold
46 var opt_nocolors
= new OptionBool("Disable colors in console outputs", "--no-colors")
51 self.option_context
.add_option
(opt_all
)
52 self.option_context
.add_option
(opt_large_class
)
53 self.option_context
.add_option
(opt_get_all
)
54 self.option_context
.add_option
(opt_feature_envy
)
55 self.option_context
.add_option
(opt_long_method
)
56 self.option_context
.add_option
(opt_no_abstract_implementation
)
57 self.option_context
.add_option
(opt_long_params
)
58 self.option_context
.add_option
(opt_long_method_threshold
)
59 self.option_context
.add_option
(opt_long_params_threshold
)
60 self.option_context
.add_option
(opt_move_generics
)
61 self.option_context
.add_option
(opt_nocolors
)
64 # Format and colorize a string heading of level 1 for console output.
66 # Default style is yellow and bold.
67 fun format_h1
(str
: String): String do
68 if opt_nocolors
.value
then return str
69 return str
.yellow
.bold
72 # Format and colorize a string heading of level 2 for console output.
74 # Default style is white and bold.
75 fun format_h2
(str
: String): String do
76 if opt_nocolors
.value
then return str
80 # Format and colorize a string heading of level 3 for console output.
82 # Default style is white and nobold.
83 fun format_h3
(str
: String): String do
84 if opt_nocolors
.value
then return str
88 # Format and colorize a string heading of level 4 for console output.
90 # Default style is green.
91 fun format_h4
(str
: String): String do
92 if opt_nocolors
.value
then return str
96 # Format and colorize a string heading of level 5 for console output.
98 # Default style is light gray.
99 fun format_p
(str
: String): String do
100 if opt_nocolors
.value
then return str
101 return str
.light_gray