@@ -216,6 +216,16 @@ pub fn parser(pre_flight_settings: PreFlightSettings) -> Command {
216
216
) )
217
217
. subcommand_value_name ( "subcommand" )
218
218
. subcommands ( tanzu_subcommands ( ) ) ;
219
+ let users_group = Command :: new ( "users" )
220
+ . about ( "Operations on users" )
221
+ . infer_subcommands ( pre_flight_settings. infer_subcommands )
222
+ . infer_long_args ( pre_flight_settings. infer_long_options )
223
+ . after_help ( color_print:: cformat!(
224
+ "<bold>Doc guide</bold>: {}" ,
225
+ ACCESS_CONTROL_GUIDE_URL
226
+ ) )
227
+ . subcommand_value_name ( "subcommand" )
228
+ . subcommands ( users_subcommands ( pre_flight_settings. clone ( ) ) ) ;
219
229
let vhosts_group = Command :: new ( "vhosts" )
220
230
. about ( "Virtual host operations" )
221
231
. infer_subcommands ( pre_flight_settings. infer_subcommands )
@@ -243,6 +253,7 @@ pub fn parser(pre_flight_settings: PreFlightSettings) -> Command {
243
253
show_group,
244
254
shovels_group,
245
255
tanzu_group,
256
+ users_group,
246
257
vhosts_group,
247
258
] ;
248
259
@@ -434,39 +445,24 @@ pub fn parser(pre_flight_settings: PreFlightSettings) -> Command {
434
445
435
446
fn list_subcommands ( pre_flight_settings : PreFlightSettings ) -> [ Command ; 19 ] {
436
447
let nodes_cmd = Command :: new ( "nodes" ) . long_about ( "Lists cluster members" ) ;
437
- let users_cmd = Command :: new ( "users" ) . long_about ( "Lists users in the internal database" ) ;
438
448
let vhosts_cmd = Command :: new ( "vhosts" )
439
449
. long_about ( "Lists virtual hosts" )
440
450
. after_help ( color_print:: cformat!(
441
451
"<bold>Doc guide</bold>: {}" ,
442
452
VIRTUAL_HOST_GUIDE_URL
443
453
) ) ;
444
-
445
- let permissions_cmd = Command :: new ( "permissions" )
446
- . long_about ( "Lists user permissions" )
454
+ let vhost_limits_cmd = Command :: new ( "vhost_limits" )
455
+ . long_about ( "Lists virtual host (resource) limits" )
447
456
. after_help ( color_print:: cformat!(
448
457
"<bold>Doc guide</bold>: {}" ,
449
- ACCESS_CONTROL_GUIDE_URL
458
+ VIRTUAL_HOST_GUIDE_URL
450
459
) ) ;
451
460
let connections_cmd = Command :: new ( "connections" )
452
461
. long_about ( "Lists client connections" )
453
462
. after_help ( color_print:: cformat!(
454
463
"<bold>Doc guide</bold>: {}" ,
455
464
CONNECTION_GUIDE_URL
456
465
) ) ;
457
- let user_connections_cmd = Command :: new ( "user_connections" )
458
- . arg (
459
- Arg :: new ( "username" )
460
- . short ( 'u' )
461
- . long ( "username" )
462
- . required ( true )
463
- . help ( "Name of the user whose connections to list" ) ,
464
- )
465
- . long_about ( "Lists client connections that authenticated with a specific username" )
466
- . after_help ( color_print:: cformat!(
467
- "<bold>Doc guide</bold>: {}" ,
468
- CONNECTION_GUIDE_URL
469
- ) ) ;
470
466
let channels_cmd = Command :: new ( "channels" )
471
467
. long_about ( "Lists AMQP 0-9-1 channels" )
472
468
. after_help ( color_print:: cformat!(
@@ -511,11 +507,25 @@ fn list_subcommands(pre_flight_settings: PreFlightSettings) -> [Command; 19] {
511
507
"<bold>Doc guide</bold>: {}" ,
512
508
OPERATOR_POLICY_GUIDE_URL
513
509
) ) ;
514
- let vhost_limits_cmd = Command :: new ( "vhost_limits" )
515
- . long_about ( "Lists virtual host (resource) limits" )
510
+ let users_cmd = Command :: new ( "users" ) . long_about ( "Lists users in the internal database" ) ;
511
+ let permissions_cmd = Command :: new ( "permissions" )
512
+ . long_about ( "Lists user permissions" )
516
513
. after_help ( color_print:: cformat!(
517
514
"<bold>Doc guide</bold>: {}" ,
518
- VIRTUAL_HOST_GUIDE_URL
515
+ ACCESS_CONTROL_GUIDE_URL
516
+ ) ) ;
517
+ let user_connections_cmd = Command :: new ( "user_connections" )
518
+ . arg (
519
+ Arg :: new ( "username" )
520
+ . short ( 'u' )
521
+ . long ( "username" )
522
+ . required ( true )
523
+ . help ( "Name of the user whose connections to list" ) ,
524
+ )
525
+ . long_about ( "Lists client connections that authenticated with a specific username" )
526
+ . after_help ( color_print:: cformat!(
527
+ "<bold>Doc guide</bold>: {}" ,
528
+ CONNECTION_GUIDE_URL
519
529
) ) ;
520
530
let user_limits_cmd = Command :: new ( "user_limits" )
521
531
. arg (
@@ -1719,6 +1729,101 @@ pub fn vhosts_subcommands(pre_flight_settings: PreFlightSettings) -> [Command; 3
1719
1729
. map ( |cmd| cmd. infer_long_args ( pre_flight_settings. infer_long_options ) )
1720
1730
}
1721
1731
1732
+ pub fn users_subcommands ( pre_flight_settings : PreFlightSettings ) -> [ Command ; 6 ] {
1733
+ let declare_cmd = Command :: new ( "declare" )
1734
+ . about ( "Creates a user" )
1735
+ . arg (
1736
+ Arg :: new ( "name" )
1737
+ . long ( "name" )
1738
+ . help ( "username" )
1739
+ . required ( true ) ,
1740
+ )
1741
+ . arg (
1742
+ Arg :: new ( "password_hash" )
1743
+ . help ( color_print:: cformat!(
1744
+ "salted password hash, see {}" ,
1745
+ PASSWORD_GUIDE_URL
1746
+ ) )
1747
+ . long ( "password-hash" )
1748
+ . required ( false )
1749
+ . default_value ( "" ) ,
1750
+ )
1751
+ . arg (
1752
+ Arg :: new ( "password" )
1753
+ . long ( "password" )
1754
+ . help ( color_print:: cformat!(
1755
+ "prefer providing a hash, see {}" ,
1756
+ PASSWORD_GUIDE_URL
1757
+ ) )
1758
+ . required ( false )
1759
+ . default_value ( "" ) ,
1760
+ )
1761
+ . arg (
1762
+ Arg :: new ( "tags" )
1763
+ . long ( "tags" )
1764
+ . help ( "a list of comma-separated tags" )
1765
+ . default_value ( "" ) ,
1766
+ ) ;
1767
+ let list_cmd = Command :: new ( "list" ) . long_about ( "Lists users in the internal database" ) ;
1768
+ let permissions_cmd = Command :: new ( "permissions" )
1769
+ . long_about ( "Lists user permissions" )
1770
+ . after_help ( color_print:: cformat!(
1771
+ "<bold>Doc guide</bold>: {}" ,
1772
+ ACCESS_CONTROL_GUIDE_URL
1773
+ ) ) ;
1774
+ let connections_cmd = Command :: new ( "connections" )
1775
+ . arg (
1776
+ Arg :: new ( "username" )
1777
+ . short ( 'u' )
1778
+ . long ( "username" )
1779
+ . required ( true )
1780
+ . help ( "Name of the user whose connections to list" ) ,
1781
+ )
1782
+ . long_about ( "Lists client connections that authenticated with a specific username" )
1783
+ . after_help ( color_print:: cformat!(
1784
+ "<bold>Doc guide</bold>: {}" ,
1785
+ CONNECTION_GUIDE_URL
1786
+ ) ) ;
1787
+ let limits_cmd = Command :: new ( "limits" )
1788
+ . arg (
1789
+ Arg :: new ( "user" )
1790
+ . long ( "user" )
1791
+ . help ( "username" )
1792
+ . required ( false ) ,
1793
+ )
1794
+ . long_about ( "Lists per-user (resource) limits" )
1795
+ . after_help ( color_print:: cformat!(
1796
+ "<bold>Doc guide</bold>: {}" ,
1797
+ USER_LIMIT_GUIDE_URL
1798
+ ) ) ;
1799
+
1800
+ let idempotently_arg = Arg :: new ( "idempotently" )
1801
+ . long ( "idempotently" )
1802
+ . value_parser ( value_parser ! ( bool ) )
1803
+ . action ( ArgAction :: SetTrue )
1804
+ . help ( "do not consider 404 Not Found API responses to be errors" )
1805
+ . required ( false ) ;
1806
+ let delete_cmd = Command :: new ( "delete" )
1807
+ . about ( "Deletes a user" )
1808
+ . arg (
1809
+ Arg :: new ( "name" )
1810
+ . long ( "name" )
1811
+ . help ( "username" )
1812
+ . required ( true ) ,
1813
+ )
1814
+ . arg ( idempotently_arg. clone ( ) ) ;
1815
+
1816
+ [
1817
+ connections_cmd,
1818
+ declare_cmd,
1819
+ delete_cmd,
1820
+ limits_cmd,
1821
+ list_cmd,
1822
+ permissions_cmd,
1823
+ ]
1824
+ . map ( |cmd| cmd. infer_long_args ( pre_flight_settings. infer_long_options ) )
1825
+ }
1826
+
1722
1827
pub fn publish_subcommands ( pre_flight_settings : PreFlightSettings ) -> [ Command ; 1 ] {
1723
1828
[ Command :: new ( "message" )
1724
1829
. about ( color_print:: cstr!( "Publishes (<red>inefficiently</red>) message(s) to a queue or a stream. <bold><red>Only suitable for development and test environments</red></bold>. Prefer messaging or streaming protocol clients!" ) )
0 commit comments