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:
- 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
andctx
arguments may beNone
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:
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.
- 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:
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.
- 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
andctx
arguments may beNone
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:
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:
- 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:
cmd (click.Command)
name (str | None)
section (str)
- Return type:
None
- format_commands(ctx, formatter)[source]¶
Extra format methods for multi methods that adds all the commands after the options.
- Parameters:
ctx (click.Context)
formatter (click.HelpFormatter)
- Return type:
None