diff --git a/newa/__init__.py b/newa/__init__.py index a44acec..9dee28f 100644 --- a/newa/__init__.py +++ b/newa/__init__.py @@ -1735,6 +1735,7 @@ class CLIContext: no_wait: bool = False restart_request: list[str] = field(factory=list) restart_result: list[str] = field(factory=list) + new_state_dir: bool = False def enter_command(self, command: str) -> None: self.logger.handlers[0].formatter = logging.Formatter( diff --git a/newa/cli.py b/newa/cli.py index c0d5a2e..ecefe60 100644 --- a/newa/cli.py +++ b/newa/cli.py @@ -200,11 +200,13 @@ def main(click_context: click.Context, ctx.logger.info(f'Using --state-dir={ctx.state_dirpath}') if not ctx.state_dirpath.exists(): + ctx.new_state_dir = True ctx.logger.debug(f'State directory {ctx.state_dirpath} does not exist, creating...') ctx.state_dirpath.mkdir(parents=True) # extract YAML files from the given archive to state-dir if extract_state_dir: + ctx.new_state_dir = False if re.match('^https?://', extract_state_dir): data = urllib.request.urlopen(extract_state_dir).read() tf = tarfile.open(fileobj=io.BytesIO(data), mode='r:*') @@ -985,6 +987,11 @@ def cmd_execute( ctx.restart_result = restart_result ctx.continue_execution = True + if ctx.continue_execution and ctx.new_state_dir: + ctx.logger.error( + 'NEWA state-dir was not specified! Use --state-dir or similar option.') + sys.exit(1) + # initialize RP connection rp_project = ctx.settings.rp_project rp_url = ctx.settings.rp_url