From 8fc027227a9679b51980a4f80d1a043fb9fc570d Mon Sep 17 00:00:00 2001 From: jodewey Date: Mon, 26 Jan 2015 18:01:50 -0800 Subject: [PATCH] Corrected `element-info` usage Deprecated the `--expand-dependencies` flag from `element-info` usage. The flag was required and not optional. We can rely on argparse to exit non-0 when the required positional argument is not provided. Change-Id: Iaf8eb962eb600760974bc33c30b809a07a23278e Closes-Bug: 1265649 --- diskimage_builder/element_dependencies.py | 14 ++++++++------ lib/common-functions | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/diskimage_builder/element_dependencies.py b/diskimage_builder/element_dependencies.py index db340cc09..be1c4f1c0 100644 --- a/diskimage_builder/element_dependencies.py +++ b/diskimage_builder/element_dependencies.py @@ -12,6 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. +from __future__ import print_function import argparse import collections import os @@ -115,16 +116,17 @@ def expand_dependencies(user_elements, elements_dir=None): def main(argv): parser = argparse.ArgumentParser() parser.add_argument('elements', nargs='+', - help='elements to inspect') + help='display dependencies of the given elements') parser.add_argument('--expand-dependencies', '-d', action='store_true', default=False, - help='Print expanded dependencies of all args') + help=('(DEPRECATED) print expanded dependencies ' + 'of all args')) args = parser.parse_args(argv[1:]) if args.expand_dependencies: - print(' '.join(expand_dependencies(args.elements))) - return 0 + print("WARNING: expand-dependencies flag is deprecated, " + "and is now on by default.", file=sys.stderr) - sys.stderr.write("ERROR: please choose an option.\n") - return -1 + print(' '.join(expand_dependencies(args.elements))) + return 0 diff --git a/lib/common-functions b/lib/common-functions index df3475cbe..1c804c4ea 100644 --- a/lib/common-functions +++ b/lib/common-functions @@ -221,7 +221,7 @@ function arg_to_elements() { fi echo "Building elements: $IMAGE_ELEMENT" - IMAGE_ELEMENT=$($SCRIPT_HOME/element-info --expand-dependencies $IMAGE_ELEMENT) + IMAGE_ELEMENT=$($SCRIPT_HOME/element-info $IMAGE_ELEMENT) export IMAGE_ELEMENT echo "Expanded element dependencies to: $IMAGE_ELEMENT"