@@ -19,7 +19,8 @@ use super::tanzu_cli::tanzu_subcommands;
1919use crate :: output:: TableStyle ;
2020use clap:: { Arg , ArgAction , ArgGroup , Command , value_parser} ;
2121use rabbitmq_http_client:: commons:: {
22- BindingDestinationType , ExchangeType , QueueType , ShovelAcknowledgementMode , SupportedProtocol ,
22+ BindingDestinationType , ExchangeType , PolicyTarget , QueueType , ShovelAcknowledgementMode ,
23+ SupportedProtocol ,
2324} ;
2425
2526pub fn parser ( ) -> Command {
@@ -228,6 +229,10 @@ pub fn parser() -> Command {
228229 . about ( "purges queues" )
229230 . subcommand_value_name ( "queue" )
230231 . subcommands ( purge_subcommands ( ) ) ,
232+ Command :: new ( "policies" )
233+ . about ( "operations on policies" )
234+ . subcommand_value_name ( "policy" )
235+ . subcommands ( policies_subcommands ( ) ) ,
231236 Command :: new ( "health_check" )
232237 . about ( "runs health checks" )
233238 . subcommand_value_name ( "check" )
@@ -597,7 +602,7 @@ fn declare_subcommands() -> [Command; 12] {
597602 Arg :: new ( "type" )
598603 . long ( "type" )
599604 . help ( "exchange type" )
600- . value_parser ( clap:: value_parser!( ExchangeType ) )
605+ . value_parser ( clap:: value_parser!( ExchangeType ) )
601606 . required ( false ) ,
602607 )
603608 . arg (
@@ -666,10 +671,10 @@ fn declare_subcommands() -> [Command; 12] {
666671 . help ( "parameter's name" )
667672 . required ( true )
668673 ) . arg (
669- Arg :: new ( "component" )
670- . long ( "component" )
671- . help ( "component (eg. federation)" )
672- . required ( true ) )
674+ Arg :: new ( "component" )
675+ . long ( "component" )
676+ . help ( "component (eg. federation)" )
677+ . required ( true ) )
673678 . arg (
674679 Arg :: new ( "value" )
675680 . long ( "value" )
@@ -687,13 +692,14 @@ fn declare_subcommands() -> [Command; 12] {
687692 . arg (
688693 Arg :: new ( "pattern" )
689694 . long ( "pattern" )
690- . help ( "queue/exchange name pattern " )
695+ . help ( "the pattern that is used to match entity ( queue, stream, exchange) names " )
691696 . required ( true ) ,
692697 )
693698 . arg (
694699 Arg :: new ( "apply_to" )
695700 . long ( "apply-to" )
696701 . help ( "entities to apply to (queues, classic_queues, quorum_queues, streams, exchanges, all)" )
702+ . value_parser ( clap:: value_parser!( PolicyTarget ) )
697703 . required ( true ) ,
698704 )
699705 . arg (
@@ -993,6 +999,60 @@ fn purge_subcommands() -> [Command; 1] {
993999 ) ]
9941000}
9951001
1002+ fn policies_subcommands ( ) -> [ Command ; 3 ] {
1003+ let declare_cmd = Command :: new ( "declare" )
1004+ . about ( "creates or updates a policy" )
1005+ . after_long_help ( color_print:: cformat!( "<bold>Doc guide:</bold>: {}" , POLICY_GUIDE_URL ) )
1006+ . arg (
1007+ Arg :: new ( "name" )
1008+ . long ( "name" )
1009+ . help ( "policy name" )
1010+ . required ( true ) ,
1011+ )
1012+ . arg (
1013+ Arg :: new ( "pattern" )
1014+ . long ( "pattern" )
1015+ . help ( "the pattern that is used to match entity (queue, stream, exchange) names" )
1016+ . required ( true ) ,
1017+ )
1018+ . arg (
1019+ Arg :: new ( "apply_to" )
1020+ . long ( "apply-to" )
1021+ . help ( "entities to apply to (queues, classic_queues, quorum_queues, streams, exchanges, all)" )
1022+ . value_parser ( clap:: value_parser!( PolicyTarget ) )
1023+ . required ( true ) ,
1024+ )
1025+ . arg (
1026+ Arg :: new ( "priority" )
1027+ . long ( "priority" )
1028+ . help ( "policy priority (only the policy with the highest priority is effective)" )
1029+ . required ( false )
1030+ . default_value ( "0" ) ,
1031+ )
1032+ . arg (
1033+ Arg :: new ( "definition" )
1034+ . long ( "definition" )
1035+ . help ( "policy definition" )
1036+ . required ( true ) ,
1037+ ) ;
1038+
1039+ let list_cmd = Command :: new ( "list" )
1040+ . long_about ( "lists policies" )
1041+ . after_long_help ( color_print:: cformat!(
1042+ "<bold>Doc guide</bold>: {}" ,
1043+ POLICY_GUIDE_URL
1044+ ) ) ;
1045+
1046+ let delete_cmd = Command :: new ( "delete" ) . about ( "deletes a policy" ) . arg (
1047+ Arg :: new ( "name" )
1048+ . long ( "name" )
1049+ . help ( "policy name" )
1050+ . required ( true ) ,
1051+ ) ;
1052+
1053+ [ declare_cmd, list_cmd, delete_cmd]
1054+ }
1055+
9961056fn health_check_subcommands ( ) -> [ Command ; 6 ] {
9971057 let node_is_quorum_critical_after_help = color_print:: cformat!(
9981058 r#"
@@ -1178,14 +1238,14 @@ fn import_subcommands() -> [Command; 1] {
11781238
11791239pub fn feature_flags_subcommands ( ) -> [ Command ; 3 ] {
11801240 let list_cmd = Command :: new ( "list" )
1181- . long_about ( "Lists feature flags and their cluster state" )
1241+ . long_about ( "lists feature flags and their cluster state" )
11821242 . after_long_help ( color_print:: cformat!(
11831243 "<bold>Doc guide</bold>: {}" ,
11841244 FEATURE_FLAG_GUIDE_URL
11851245 ) ) ;
11861246
11871247 let enable_cmd = Command :: new ( "enable" )
1188- . long_about ( "Enables a feature flag" )
1248+ . long_about ( "enables a feature flag" )
11891249 . after_long_help ( color_print:: cformat!(
11901250 "<bold>Doc guide</bold>: {}" ,
11911251 FEATURE_FLAG_GUIDE_URL
@@ -1198,7 +1258,7 @@ pub fn feature_flags_subcommands() -> [Command; 3] {
11981258 ) ;
11991259
12001260 let enable_all_cmd = Command :: new ( "enable_all" )
1201- . long_about ( "Enables all stable feature flags" )
1261+ . long_about ( "enables all stable feature flags" )
12021262 . after_long_help ( color_print:: cformat!(
12031263 "<bold>Doc guide</bold>: {}" ,
12041264 FEATURE_FLAG_GUIDE_URL
@@ -1209,14 +1269,14 @@ pub fn feature_flags_subcommands() -> [Command; 3] {
12091269
12101270pub fn deprecated_features_subcommands ( ) -> [ Command ; 2 ] {
12111271 let list_cmd = Command :: new ( "list" )
1212- . long_about ( "Lists deprecated features" )
1272+ . long_about ( "lists deprecated features" )
12131273 . after_long_help ( color_print:: cformat!(
12141274 "<bold>Doc guide</bold>: {}" ,
12151275 DEPRECATED_FEATURE_GUIDE_URL
12161276 ) ) ;
12171277
12181278 let list_in_use_cmd = Command :: new ( "list_used" )
1219- . long_about ( "Lists the deprecated features that are found to be in use in the cluster" )
1279+ . long_about ( "lists the deprecated features that are found to be in use in the cluster" )
12201280 . after_long_help ( color_print:: cformat!(
12211281 "<bold>Doc guide</bold>: {}" ,
12221282 DEPRECATED_FEATURE_GUIDE_URL
0 commit comments