Skip to content

Commit

Permalink
cli: add more flags to 'popper sh' command (#923)
Browse files Browse the repository at this point in the history
Added --skip-pull, --skip-clone, --config, and --substitution flags to 'popper sh'

fixes #913
  • Loading branch information
maruthgoyal committed Sep 25, 2020
1 parent 910eaa8 commit 1891ccd
Showing 1 changed file with 34 additions and 3 deletions.
37 changes: 34 additions & 3 deletions src/popper/commands/cmd_sh.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,55 @@
required=False,
default="/bin/bash",
)
@click.option(
"--skip-pull",
help="Skip pulling container images (assume they exist in local cache).",
required=False,
is_flag=True,
)
@click.option(
"--skip-clone",
help="Skip cloning repositories (assume they have been cloned).",
required=False,
is_flag=True,
)
@click.option(
"-s",
"--substitution",
help="A key-value pair defining a substitution. " "Can be given multiple times.",
required=False,
default=list(),
multiple=True,
)
@click.option(
"-c", "--conf", help="Path to file with configuration options.", required=False
)
@pass_context
def cli(ctx, file, step, entrypoint):
def cli(ctx, file, step, entrypoint, skip_pull, skip_clone, substitution, conf):
"""Opens an interactive shell using all the attributes defined in the workflow file
for the given STEP, but ignoring ``runs`` and ``args``. By default, it invokes
/bin/bash. If you need to invoke another one, you can specify it in the --entrypoint
flag.
NOTE: this command only works for (local) host runner in Docker.
"""
wf = WorkflowParser.parse(file=file, step=step, immutable=False)
wf = WorkflowParser.parse(
file=file, step=step, immutable=False, substitutions=substitution
)

# override entrypoint
step = wf.steps[0]
step.args = []
step.runs = entrypoint

# configure runner so containers execute in attached mode and create a tty
config = ConfigLoader.load(engine_name="docker", pty=True)
config = ConfigLoader.load(
engine_name="docker",
pty=True,
skip_pull=skip_pull,
skip_clone=skip_clone,
config_file=conf,
)

with WorkflowRunner(config) as runner:
try:
Expand Down

0 comments on commit 1891ccd

Please sign in to comment.