@@ -84,7 +84,7 @@ def handle_bite_list(host: Host, args: argparse.Namespace, extras: List[str]) ->
8484
8585def handle_bite_install (host : Host , args : argparse .Namespace , extras : List [str ]) -> None :
8686 """
87- Handle the 'install' command, installing a module.
87+ Handle the 'install' command, installing module.
8888 """
8989 if extras :
9090 host .get_argparser ().error (f"Invalid arguments: { extras } " )
@@ -95,3 +95,40 @@ def handle_bite_install(host: Host, args: argparse.Namespace, extras: List[str])
9595 upgrade = args .upgrade
9696
9797 module .install (source , host .MODULES_DIR , upgrade = upgrade )
98+
99+ def handle_bite_update (host : Host , args : argparse .Namespace , extras : List [str ]) -> None :
100+ """
101+ Handle the 'update' command, updating module.
102+ """
103+
104+ if extras :
105+ host .get_argparser ().error (f"Invalid arguments: { extras } " )
106+
107+ from . import module
108+
109+ modules = getattr (args , 'modules' , [])
110+ all_modules = args .all
111+
112+ sources : List [str ] = []
113+ hmods = host .get_modules ()
114+ if all_modules :
115+ for mod in hmods .values ():
116+ if mod .updatable :
117+ sources .append (mod .update_url )
118+ elif modules :
119+ for id in modules :
120+ mod = hmods .get (id )
121+ if mod is None :
122+ host .get_argparser ().error (f"Module '{ id } ' not found." )
123+ if mod .updatable :
124+ sources .append (mod .update_url )
125+ else :
126+ host .get_argparser ().error (f"Module '{ id } ' is not updatable." )
127+ else :
128+ host .get_argparser ().error ("No modules specified for update." )
129+
130+ for source in sources :
131+ module .install (source , host .MODULES_DIR , upgrade = True )
132+
133+ if not sources :
134+ print ("No modules to update." )
0 commit comments