@@ -66,6 +66,12 @@ def cli() -> None:
6666 default = None ,
6767 multiple = True ,
6868)
69+ @click .option (
70+ "--selected-rule" ,
71+ help = "Rule to select." ,
72+ default = None ,
73+ multiple = True ,
74+ )
6975@click .option (
7076 "--manifest" ,
7177 "-m" ,
@@ -121,6 +127,7 @@ def lint( # noqa: PLR0912, PLR0913, C901
121127 select : tuple [str ],
122128 namespace : list [str ],
123129 disabled_rule : list [str ],
130+ selected_rule : list [str ],
124131 manifest : Path ,
125132 run_dbt_parse : bool ,
126133 fail_project_under : float ,
@@ -136,12 +143,19 @@ def lint( # noqa: PLR0912, PLR0913, C901
136143 if manifest_provided and run_dbt_parse :
137144 raise click .UsageError ("--run-dbt-parse cannot be used with --manifest." )
138145
146+ if len (selected_rule ) > 0 and len (disabled_rule ) > 0 :
147+ raise click .UsageError (
148+ "--disabled-rule and --selected-rule cannot be used together."
149+ )
150+
139151 config = Config ()
140152 config .load ()
141153 if namespace :
142154 config .overload ({"rule_namespaces" : namespace })
143155 if disabled_rule :
144156 config .overload ({"disabled_rules" : disabled_rule })
157+ if selected_rule :
158+ config .overload ({"selected_rules" : selected_rule })
145159 if fail_project_under :
146160 config .overload ({"fail_project_under" : fail_project_under })
147161 if fail_any_item_under :
@@ -194,6 +208,12 @@ def lint( # noqa: PLR0912, PLR0913, C901
194208 default = None ,
195209 multiple = True ,
196210)
211+ @click .option (
212+ "--selected-rule" ,
213+ help = "Rule to select." ,
214+ default = None ,
215+ multiple = True ,
216+ )
197217@click .option (
198218 "--title" ,
199219 help = "Page title (Markdown only)." ,
@@ -207,14 +227,25 @@ def lint( # noqa: PLR0912, PLR0913, C901
207227 default = "terminal" ,
208228)
209229def list_command (
210- namespace : list [str ], disabled_rule : list [str ], title : str , format : str
230+ namespace : list [str ],
231+ disabled_rule : list [str ],
232+ selected_rule : list [str ],
233+ title : str ,
234+ format : str ,
211235) -> None :
212236 """Display rules list."""
237+ if len (selected_rule ) > 0 and len (disabled_rule ) > 0 :
238+ raise click .UsageError (
239+ "--disabled-rule and --selected-rule cannot be used together."
240+ )
241+
213242 config = Config ()
214243 config .load ()
215244 if namespace :
216245 config .overload ({"rule_namespaces" : namespace })
217246 if disabled_rule :
218247 config .overload ({"disabled_rules" : disabled_rule })
248+ if selected_rule :
249+ config .overload ({"selected_rules" : selected_rule })
219250
220251 display_catalog (config , title , format )
0 commit comments