@@ -210,6 +210,10 @@ def _exec_cmd(args):
210210RED_COLOR_CODE = 9
211211
212212
213+ class ArgumentError (Exception ):
214+ pass
215+
216+
213217class Step (object ):
214218 """
215219 Class labels an installation Step and is expected to be invoked as
@@ -330,9 +334,24 @@ def _announce_success(virtualenv_location):
330334
331335
332336def _print_in_foreground (message , color_number ):
337+ """
338+ Function prints a given `message` on the terminal in the foreground. `color_number`
339+ is a number between and including 0 and 255. FOr a list of color codes see:
340+
341+ https://misc.flogisoft.com/bash/tip_colors_and_formatting#background1
342+
343+ On Windows, `color_number` is rejected, and hence not used. At present, PowerShell
344+ is able to recognize ANSI/VT100 escape sequences, however, CMD prompt is not.
345+
346+ :param message: a string to print in the foreground on the terminal
347+ :param color_number: an integer between and including 0 and 255 representing
348+ a color
349+ :return: None
350+ """
333351 if sys .platform .startswith ('win32' ):
334352 print (message )
335353 else :
354+ # Courtesy https://misc.flogisoft.com/bash/tip_colors_and_formatting
336355 print (
337356 "\033 [38;5;{color_number}m{message}\033 [0m" .format (
338357 color_number = color_number ,
@@ -468,17 +487,23 @@ def _generate_ebcli_wrappers(virtualenv_location):
468487
469488
470489@Step ('Installing EBCLI' )
471- def _install_ebcli (quiet , version ):
490+ def _install_ebcli (quiet , version , ebcli_source ):
472491 """
473492 Function installs the awsebcli presumably within the virtualenv,
474493 ".ebcli-virtual-env", created and activated by this script apriori.
475494 If `version` is passed, the specific version of the EBCLI is installed.
495+
496+ The presence of `version` and `ebcli_source` will lead to an exception
497+ as they represent two different ways of installing the EBCLI.
498+
476499 :param quiet: whether to display the output of awsebcli installation to
477500 the terminal or not
478501 :param version: the specific version of awsebcli to install
479502 :return None
480503 """
481- if version :
504+ if ebcli_source :
505+ install_args = ['pip' , 'install' , '{}' .format (ebcli_source .strip ())]
506+ elif version :
482507 install_args = ['pip' , 'install' , 'awsebcli=={}' .format (version .strip ())]
483508 else :
484509 install_args = [
@@ -661,11 +686,24 @@ def _parse_arguments():
661686 action = 'store_true' ,
662687 help = 'enable quiet mode to display only minimal, necessary output'
663688 )
689+ parser .add_argument (
690+ '-s' , '--ebcli-source' ,
691+ help = 'filesystem path to a Git repository of the EBCLI, or a .zip or .tar file of '
692+ 'the EBCLI source code; useful when testing a development version of the EBCLI.'
693+ )
664694 parser .add_argument (
665695 '-v' , '--version' ,
666696 help = 'version of EBCLI to install'
667697 )
668- return parser .parse_args ()
698+
699+ arguments = parser .parse_args ()
700+
701+ if arguments .version and arguments .ebcli_source :
702+ raise ArgumentError (
703+ '"--version" and "--ebcli-source" cannot be used together '
704+ 'because they represent two distinct sources of the EBCLI.'
705+ )
706+ return arguments
669707
670708
671709def _pip_executable_found (quiet ):
@@ -735,6 +773,10 @@ def _python_script_body(virtualenv_location):
735773 arguments_context .quiet
736774 )
737775 _activate_virtualenv (virtualenv_location )
738- _install_ebcli (arguments_context .quiet , arguments_context .version )
776+ _install_ebcli (
777+ arguments_context .quiet ,
778+ arguments_context .version ,
779+ arguments_context .ebcli_source
780+ )
739781 _generate_ebcli_wrappers (virtualenv_location )
740782 _announce_success (virtualenv_location )
0 commit comments