Skip to content

Commit

Permalink
Support multiple actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Filippo Cremonese committed Feb 8, 2021
1 parent ae5c0aa commit 00793df
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 33 deletions.
25 changes: 15 additions & 10 deletions orchestra/cmds/clone.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,29 @@ def install_subcommand(sub_argparser):
help="Clone a component",
parents=[execution_options],
)
cmd_parser.add_argument("component", help="Name of the component to clone")
cmd_parser.add_argument("components", nargs="+", help="Name of the components to clone")
cmd_parser.add_argument("--no-force", action="store_true", help="Don't force execution of the root action")


def handle_clone(args):
config = Configuration(use_config_cache=args.config_cache)
build = config.get_build(args.component)

if not build:
suggested_component_name = config.get_suggested_component_name(args.component)
logger.error(f"Component {args.component} not found! Did you mean {suggested_component_name}?")
return 1
actions = set()
for component in args.components:
build = config.get_build(component)

if not build.component.clone:
logger.error("This component does not have a git repository configured!")
return 1
if not build:
suggested_component_name = config.get_suggested_component_name(component)
logger.error(f"Component {component} not found! Did you mean {suggested_component_name}?")
return 1

executor = Executor(args, [build.component.clone], no_force=args.no_force)
if not build.component.clone:
logger.error("This component does not have a git repository configured!")
return 1

actions.add(build.component.clone)

executor = Executor(args, actions, no_force=args.no_force)
failed = executor.run()
exitcode = 1 if failed else 0
return exitcode
19 changes: 12 additions & 7 deletions orchestra/cmds/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def install_subcommand(sub_argparser):
help="Run configure script",
parents=[execution_options, build_options]
)
cmd_parser.add_argument("component", help="Name of the component to configure")
cmd_parser.add_argument("components", nargs="+", help="Name of the components to configure")
cmd_parser.add_argument("--no-force", action="store_true", help="Don't force execution of the root action")
cmd_parser.add_argument("--no-deps", action="store_true", help="Only execute the requested action")

Expand All @@ -21,14 +21,19 @@ def handle_configure(args):
force_from_source=args.from_source,
use_config_cache=args.config_cache,
)
build = config.get_build(args.component)

if not build:
suggested_component_name = config.get_suggested_component_name(args.component)
logger.error(f"Component {args.component} not found! Did you mean {suggested_component_name}?")
return 1
actions = set()
for component in args.components:
build = config.get_build(component)

executor = Executor(args, [build.configure], no_deps=args.no_deps, no_force=args.no_force)
if not build:
suggested_component_name = config.get_suggested_component_name(component)
logger.error(f"Component {component} not found! Did you mean {suggested_component_name}?")
return 1

actions.add(build.configure)

executor = Executor(args, actions, no_deps=args.no_deps, no_force=args.no_force)
failed = executor.run()
exitcode = 1 if failed else 0
return exitcode
20 changes: 11 additions & 9 deletions orchestra/cmds/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def install_subcommand(sub_argparser):
help="Print dependency graph (dot format)",
parents=[build_options]
)
cmd_parser.add_argument("component", nargs="?")
cmd_parser.add_argument("components", nargs="*")
cmd_parser.add_argument("--all-builds", action="store_true",
help="Include all builds instead of only the default one.\n"
"Can't be used with --solved")
Expand All @@ -36,17 +36,19 @@ def handle_graph(args):
force_from_source=args.from_source,
use_config_cache=args.config_cache,
)
if args.component:
build = config.get_build(args.component)
actions = set()

if not build:
suggested_component_name = config.get_suggested_component_name(args.component)
logger.error(f"Component {args.component} not found! Did you mean {suggested_component_name}?")
return 1
if args.components:
for component in args.components:
build = config.get_build(component)

actions = [build.install]
if not build:
suggested_component_name = config.get_suggested_component_name(component)
logger.error(f"Component {component} not found! Did you mean {suggested_component_name}?")
return 1

actions.add(build.install)
else:
actions = set()
for component in config.components.values():
if args.all_builds:
for build in component.builds.values():
Expand Down
17 changes: 10 additions & 7 deletions orchestra/cmds/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def install_subcommand(sub_argparser):
help="Build and install a component",
parents=[build_options, execution_options],
)
cmd_parser.add_argument("component", help="Name of the component to install")
cmd_parser.add_argument("components", nargs="+", help="Name of the components to install")
cmd_parser.add_argument("--no-deps", action="store_true", help="Only execute the requested action")
cmd_parser.add_argument("--no-merge", action="store_true", help="Do not merge files into orchestra root")
cmd_parser.add_argument("--create-binary-archives", action="store_true", help="Create binary archives")
Expand All @@ -26,14 +26,17 @@ def handle_install(args):
use_config_cache=args.config_cache,
create_binary_archives=args.create_binary_archives,
)
build = config.get_build(args.component)

if not build:
suggested_component_name = config.get_suggested_component_name(args.component)
logger.error(f"Component {args.component} not found! Did you mean {suggested_component_name}?")
return 1
actions = set()
for component in args.components:
build = config.get_build(component)
if not build:
suggested_component_name = config.get_suggested_component_name(component)
logger.error(f"Component {component} not found! Did you mean {suggested_component_name}?")
return 1
actions.add(build.install)

executor = Executor(args, [build.install], no_deps=args.no_deps, no_force=args.no_force)
executor = Executor(args, actions, no_deps=args.no_deps, no_force=args.no_force)
failed = executor.run()
exitcode = 1 if failed else 0
return exitcode

0 comments on commit 00793df

Please sign in to comment.