Skip to content

octoprint.cli#

legacy_options = bulk_options([hidden_option('--host', type=click.STRING, callback=set_ctx_obj_option), hidden_option('--port', type=click.INT, callback=set_ctx_obj_option), hidden_option('--logging', type=click.Path(), callback=set_ctx_obj_option), hidden_option('--debug', '-d', is_flag=True, callback=set_ctx_obj_option), hidden_option('--daemon', type=click.Choice(['start', 'stop', 'restart']), callback=set_ctx_obj_option), hidden_option('--pid', type=click.Path(), default='/tmp/octoprint.pid', callback=set_ctx_obj_option), hidden_option('--iknowwhatimdoing', 'allow_root', is_flag=True, callback=set_ctx_obj_option), hidden_option('--ignore-blacklist', 'ignore_blacklist', is_flag=True, callback=set_ctx_obj_option)]) module-attribute #

Legacy options available directly on the "octoprint" command in earlier versions. Kept available for reasons of backwards compatibility, but hidden from the generated help pages.

pass_octoprint_ctx = click.make_pass_decorator(OctoPrintContext, ensure=True) module-attribute #

Decorator to pass in the :class:OctoPrintContext instance.

HiddenOption #

Bases: click.Option

Custom option sub class with empty help.

OctoPrintContext(configfile = None, basedir = None, verbosity = 0, safe_mode = False) #

Custom context wrapping the standard options.

bulk_options(options) #

Utility decorator to decorate a function with a list of click decorators.

The provided list of options will be reversed to ensure correct processing order (inverse from what would be intuitive).

hidden_option(*param_decls, **attrs) #

Attaches a hidden option to the command. All positional arguments are passed as parameter declarations to Option; all keyword arguments are forwarded unchanged. This is equivalent to creating an Option instance manually and attaching it to the Command.params list.

init_platform_for_cli(ctx) #

Performs a basic platform initialization for the CLI.

Plugin implementations will be initialized, but only with a subset of the usual property injections:

  • _identifier and everything else parsed from metadata
  • _logger
  • _connectivity_checker
  • _environment_detector
  • _event_bus
  • _plugin_manager
  • _settings

set_ctx_obj_option(ctx, param, value) #

Helper for setting eager options on the context.

standard_options(hidden = False) #

Decorator to add the standard options shared among all "octoprint" commands.

If hidden is set to True, the options will be available on the command but not listed in its help page.