44"""
55import argparse
66import logging
7+ from pathlib import Path
78
89from lib .common import HostAddress
910from lib .tools import logger
11+ from lib .tools .inventory import into_inventory , load_inventory
1012from lib .tools .tasks .update import update_all
1113
1214def _command_update (args ):
13- update_all (args .hosts , args .repos )
15+ if args .inventory :
16+ inventory = load_inventory (args .inventory )
17+ else :
18+ inventory = into_inventory (args .hosts , args .repos )
19+
20+ update_all (inventory )
1421
1522
1623def cli ():
@@ -27,11 +34,13 @@ def cli():
2734 description = "Run update tasks on target(s)" ,
2835 help = "Run update tasks on target(s)" ,
2936 )
30- subparser_cmd_update .add_argument (
31- "hosts" , type = HostAddress , metavar = "HOST" , nargs = "+" , help = "Hostname(s) or ip address(es) of target(s)"
37+ cmd_update_excl_grp = subparser_cmd_update .add_mutually_exclusive_group (required = True )
38+ cmd_update_excl_grp .add_argument (
39+ "-H" , "--hosts" , type = HostAddress , metavar = "HOST" , nargs = "+" , help = "Hostname(s) or ip address(es) of target(s)"
3240 )
41+ cmd_update_excl_grp .add_argument ("-i" , "--inventory" , type = Path , help = "Use an hosts inventory file" )
3342 subparser_cmd_update .add_argument (
34- "--enablerepo" ,
43+ "-e" , "- -enablerepo" ,
3544 metavar = "REPO" ,
3645 action = "append" ,
3746 dest = "repos" ,
0 commit comments