def add_command(self, project, name, command_type, command, env_spec_name=None, supports_http_options=None): """Add a command to anaconda-project.yml. Returns a ``Status`` subtype (it won't be a ``RequirementStatus`` as with some other functions, just a plain status). Args: project (Project): the project name (str): name of the command command_type (str): choice of `bokeh_app`, `notebook`, `unix` or `windows` command command (str): the command line or filename itself env_spec_name (str): env spec to use with this command supports_http_options (bool): whether command supports --anaconda-project-* http server options Returns: a ``Status`` instance """ return project_ops.add_command( project=project, name=name, command_type=command_type, command=command, env_spec_name=env_spec_name, supports_http_options=supports_http_options)
def add_command(project_dir, name, command_type, command, env_spec_name, supports_http_options): """Add command to anaconda-project.yml. Returns: int exit code """ project = load_project(project_dir) command_as_filename = os.path.join(project.directory_path, command) if command_type is None and command.endswith(".ipynb") and os.path.isfile( command_as_filename): command_type = 'notebook' if command_type is None or command_type == 'ask': command_type = _ask_command(name) if command_type is None: # EOF, probably not an interactive console print("Specify the --type option to add this command.", file=sys.stderr) return 1 status = project_ops.add_command(project, name, command_type, command, env_spec_name, supports_http_options) if not status: console_utils.print_status_errors(status) return 1 else: print( "Added a command '%s' to the project. Run it with `anaconda-project run %s`." % (name, name)) return 0