maestral.cli.core

This module provides custom click command line parameters for Maestral such DropboxPath, ConfigKey and ConfigName, as well as an ordered command group class which prints its help output in sections.

Module Contents

class maestral.cli.core.DropboxPath(file_okay=True, dir_okay=True)[source]

Bases: click.ParamType

A command line parameter representing a Dropbox path

This parameter type provides custom shell completion for items inside the local Dropbox folder.

Parameters:
  • file_okay (bool) – Controls if a file is a possible value.

  • dir_okay (bool) – Controls if a directory is a possible value.

name = 'Dropbox path'[source]
envvar_list_splitter[source]
convert(value, param, ctx)[source]

Convert the value to the correct type. This is not called if the value is None (the missing value).

This must accept string values from the command line, as well as values that are already the correct type. It may also convert other compatible types.

The param and ctx arguments may be None in certain situations, such as when converting prompt input.

If the value cannot be converted, call fail() with a descriptive message.

Parameters:
  • value (str | None) – The value to convert.

  • param (click.Parameter | None) – The parameter that is using this type to convert its value. May be None.

  • ctx (click.Context | None) – The current context that arrived at this value. May be None.

Return type:

str | None

shell_complete(ctx, param, incomplete)[source]

Return a list of CompletionItem objects for the incomplete value. Most types do not provide completions, but some do, and this allows custom types to provide custom completions as well.

Parameters:
  • ctx (click.Context | None) – Invocation context for this command.

  • param (click.Parameter | None) – The parameter that is requesting completion.

  • incomplete (str) – Value being completed. May be empty.

Return type:

list[click.shell_completion.CompletionItem]

Added in version 8.0.

class maestral.cli.core.ConfigKey[source]

Bases: click.ParamType

A command line parameter representing a config key

This parameter type provides custom shell completion for existing config keys.

name = 'key'[source]
shell_complete(ctx, param, incomplete)[source]

Return a list of CompletionItem objects for the incomplete value. Most types do not provide completions, but some do, and this allows custom types to provide custom completions as well.

Parameters:
  • ctx (click.Context | None) – Invocation context for this command.

  • param (click.Parameter | None) – The parameter that is requesting completion.

  • incomplete (str) – Value being completed. May be empty.

Return type:

list[click.shell_completion.CompletionItem]

Added in version 8.0.

class maestral.cli.core.ConfigName(existing=True)[source]

Bases: click.ParamType

A command line parameter representing a Dropbox path

This parameter type provides custom shell completion for existing config names.

Parameters:

existing (bool) – If True require an existing config, otherwise create a new config on demand.

name = 'config'[source]
convert(value, param, ctx)[source]

Convert the value to the correct type. This is not called if the value is None (the missing value).

This must accept string values from the command line, as well as values that are already the correct type. It may also convert other compatible types.

The param and ctx arguments may be None in certain situations, such as when converting prompt input.

If the value cannot be converted, call fail() with a descriptive message.

Parameters:
  • value (str | None) – The value to convert.

  • param (click.Parameter | None) – The parameter that is using this type to convert its value. May be None.

  • ctx (click.Context | None) – The current context that arrived at this value. May be None.

Return type:

str | None

shell_complete(ctx, param, incomplete)[source]

Return a list of CompletionItem objects for the incomplete value. Most types do not provide completions, but some do, and this allows custom types to provide custom completions as well.

Parameters:
  • ctx (click.Context | None) – Invocation context for this command.

  • param (click.Parameter | None) – The parameter that is requesting completion.

  • incomplete (str) – Value being completed. May be empty.

Return type:

list[click.shell_completion.CompletionItem]

Added in version 8.0.

class maestral.cli.core.OrderedGroup(name=None, commands=None, **attrs)[source]

Bases: click.Group

Click command group with customizable sections of help output.

Parameters:
  • name (Optional[str])

  • commands (Optional[Union[MutableMapping[str, Command], Sequence[Command]]])

  • attrs (Any)

sections: dict[str, list[tuple[str, click.Command]]][source]
add_command(cmd, name=None, section='')[source]

Registers another Command with this group. If the name is not provided, the name of the command is used.

Parameters:
Return type:

None

format_commands(ctx, formatter)[source]

Extra format methods for multi methods that adds all the commands after the options.

Parameters:
Return type:

None

exception maestral.cli.core.CliException(message)[source]

Bases: click.ClickException

Subclass of click.CliException exception with a nicely formatted error message.

Parameters:

message (str)

show(file=None)[source]
Parameters:

file (Any)

Return type:

None