@@ -58,10 +58,10 @@ def initialize():
5858 parser_spin .set_defaults (func = spin )
5959
6060 # reg command
61- parser_reg = subparsers .add_parser ('reg ' , help =
61+ parser_reg = subparsers .add_parser ('registry ' , help =
6262 "Modifies a registry key." )
6363 parser_reg .add_argument ('profile' , help =
64- 'Name of the profile to add the regkey modification .' )
64+ 'Name of the profile to modify .' )
6565 parser_reg .add_argument ('modtype' , help =
6666 'The modification type (add, delete or modify).' )
6767 parser_reg .add_argument ('key' , help =
@@ -76,10 +76,10 @@ def initialize():
7676 parser_reg .set_defaults (func = reg )
7777
7878 # dir command
79- parser_dir = subparsers .add_parser ('dir ' , help =
79+ parser_dir = subparsers .add_parser ('directory ' , help =
8080 'Modifies a directory' )
8181 parser_dir .add_argument ('profile' , help =
82- 'Name of the profile to apply modifications .' )
82+ 'Name of the profile to modify .' )
8383 parser_dir .add_argument ('modtype' , help =
8484 'Modification type (delete or add).' )
8585 parser_dir .add_argument ('dirpath' , help =
@@ -91,6 +91,15 @@ def initialize():
9191 # parser_wallpaper = subparsers.add_parser('wallpaper', help=
9292 # '')
9393
94+ # package command
95+ parser_package = subparsers .add_parser ('package' , help =
96+ 'Adds package to install' )
97+ parser_package .add_argument ('profile' , help =
98+ 'Name of the profile to modify.' )
99+ parser_package .add_argument ('package' , help =
100+ 'Name of the package to install' )
101+ parser_package .set_defaults (func = package )
102+
94103 # no command
95104 parser .set_defaults (func = default )
96105
@@ -304,12 +313,12 @@ def directory(parser, args):
304313 if args .modtype == "add" :
305314 command = "New-Item"
306315 line = "{0} -Path {1} -Type directory\r \n " .format (command , args .dirpath )
307- print ("Adding: " + line )
316+ print ("Adding directory: {}" . format ( args . dirpath ) )
308317 elif args .modtype == "delete" :
309318 command = "Remove-Item"
310319 line = "{0} -Path {1}\r \n " .format (
311320 command , args .dirpath )
312- print ("Adding: " + line )
321+ print ("Removing directory: {}" . format ( args . dirpath ) )
313322 else :
314323 print ("Directory modification type invalid." )
315324 print ("Valid ones are: add, delete." )
@@ -329,6 +338,24 @@ def directory(parser, args):
329338 json .dump (config , f , sort_keys = True , indent = 4 , separators = (',' , ': ' ))
330339 f .close ()
331340
341+ def package (parser , args ):
342+ """ Adds a package to install with Chocolatey."""
343+ line = "cinst {} -y\r \n " .format (args .package )
344+ print ("Adding Chocolatey package: {}" .format (args .package ))
345+ filename = "scripts/windows/{}.ps1" .format (args .profile )
346+ f = open (filename , "a" )
347+ f .write (line )
348+ f .close ()
349+
350+ """ Add the script to the profile."""
351+ config = load_config (args .profile )
352+ provisioners_list = config ["provisioners" ][0 ]["scripts" ]
353+ """ If the script is not already in the profile."""
354+ if filename not in provisioners_list :
355+ provisioners_list .append (filename )
356+ f = open ("profiles/{}.json" .format (args .profile ), "w" )
357+ json .dump (config , f , sort_keys = True , indent = 4 , separators = (',' , ': ' ))
358+ f .close ()
332359
333360if __name__ == "__main__" :
334361 try :
0 commit comments