For every star on GitHub, we'll donate $2 to clean up our waterways. Star us now!
This section of the guide provides guidance on how to work with the Meltano CLI, which serves as the primary user interface of Meltano, and is built with the Python package: click.
See the prerequisite section for instructions on how to set up a development environment and dependencies.
The meltano
CLI is the primary interface for interacting with Meltano. It’s often the first introduction to meltano
that a users experiences when browsing the docs or experimenting with the CLI. As such, we aim to provide a clear and
consistent interface that is easy to use. This guide aims to codify the design guidelines for the CLI so that
contributors can easily update or extend the CLI with new features, commands, options, and enhancements.
This document is somewhat aspirational and a work in progress. Portions of the CLI may violate the design and style guidelines, but we aim to update the CLI overtime to ensure that it is as consistent as possible.
Groups, Commands, Sub-commands, Arguments, Options, and Flags often have slightly different meanings for users. So are
defined as follows for use in meltano
.
meltano schedule
feature-group contains commands related to managing Meltano schedules.--dry-run/--verbose
) or named
input options (e.g. --tasks=
). They come in two forms. A long form: --option-name
, and a short form: -o
.Given a command like meltano job set JOB_NAME --tasks=[<task>...]
:
meltano
is the global click command group for Meltano. This is the main entry point to the CLI. When we refer to global options this is the level we refer to.job
is the click command group for the job
command. This is the main command group for the job
command. This is typically the top level for a Meltano feature.set
is a sub-command
of the job
command.JOB_NAME
is an argument
of the set
sub-command.--tasks
is named option
of the set
sub-command.For a technical explanation of how commands and groups work see https://click.palletsprojects.com/en/8.0.x/commands/
For options you expect to be used frequently or for options with excessively long names, you may include both the long
AND short variation of the option. For example --help
and -h
, --force
and -f
. However, you should avoid using
the short form if it is ambiguous or is likely to overlap with another option in the same global command group. For
example avoid using -t
as a short form for --tasks
as it may be confused with a hypothetical --test
option.
Note that in documentation like guides and walkthrough the long form is always preferred. The short version alone should never be used in documentation.
remove
, set
, list
, get
as sub-commands to perform work within a group where appropriate.meltano <feature-group> add <something>
meltano <feature-group> delete <something>
meltano <feature-group> get <something>
add
and remove
to create or remove a construct like “schedule” or “job”set
to override or update a construct after creation as in meltano jobs JOB_NAME set
get
, set
, list
, clear
for operating on variable like artifacts like “state” and “secrets”list
to enumerate items as in meltano job list
describe
to show details about an itemWhen creating global flags, default to upper case letters for short options, and lower case letter for argument level options. Unless a common industry convention already exists to use the lower case variation.
Defaulting global short flags to upper case letters can help prevent ambiguity should a collision between a global flag and an argument level option occur. e.g.
meltano [-L/--log-level LEVEL] SOME_COMMAND [-l/--last-thing]
The caveat to this is common and expected global short options. For example -h
and --help
.
Avoid reusing a short option if at all possible to avoid potential confusion. An example where short flag should not be reused:
# ambiguous use that should be avoided
meltano somecommand run SOME_TASK [-t/--test SOME_TEST]
meltano somecommand set [-t/--task SOME_TASK]
In scenario’s like this you have three paths.
-k/--task
and -t/--test
.Default to human-readable plain text output for most commands by default. In cases where you expect users to also want
to programmatically consume the output, you should allow the user to specify the output format via the --format
option.
The --format
option should still default to text
unless the user explicitly specifies a format. The two primary
formats are:
text
: human-readable plain text output.json
: JSON output.In the future we may add support for other formats (e.g. yaml
).
Feature groups should have fully documented help and usage, that contains at least basic invocation examples. And link to the CLI documentation for that specific feature group for more details.
Usage: meltano job [OPTIONS] COMMAND [ARGS]...
Manage jobs.
Example usage:
# This help
meltano job --help
# List all jobs in JSON format
meltano job list --format json
# List a named job
meltano job list [JOB_NAME]
# Create a new job with a single task representing a single run command.
meltano job add NAME --tasks 'tap mapper target command:arg1'
# Create a new job with multiple tasks each representing a run command.
# The list of tasks must be yaml formatted and consist of a list of strings, list of string lists, or mix of both.
meltano job add NAME --tasks '["tap mapper target", "tap2 target2", ...]'
meltano job add NAME --tasks '[["tap target dbt:run", "tap2 target2", ...], ...]'
# Remove a named job
meltano job remove NAME
Read more at https://docs.meltano.com/reference/command-line-interface#jobs
Options:
--database-uri TEXT System database URI.
--help Show this message and exit.
Commands:
add Add a new job with tasks.
list List job(s).
remove Remove a job.
set Update an existing jobs tasks
For required items such as commands and arguments, use text without brackets or braces. In the following examples, all words and arguments are required:
meltano run JOB_NAME
meltano invoke PLUGIN_NAME
meltano schedule list
meltano schedule remove SCHEDULE_NAME
Use square brackets around an optional items. If there’s more than one optional item, enclose each item in
its own set of square brackets. In the following example the --log-level
and --dump
are optional, while PLUGIN_NAME
is required:
meltano [--log-level=LEVEL] invoke [--dump=config] PLUGIN_NAME
Use curly braces ({}
) to indicate that the user must choose one—and only one—of the items inside the braces. Use
PIPES (|
) to separate the items:
meltano schedule {list|remove}
Use three trailing dots and no spaces (...
) to indicate that the user can specify multiple values for the items:
meltano run BLOCKS ...
meltano install [] [PLUGIN_NAME] ...
For official documentation such as walkthroughs and guides use the long form of the flag. For example:
meltano --environment=PROD
In help output and general examples default to the long form or provide combined examples of the short and long form:
meltano [-E/--environment ENVIRONMENT]
When writing help output it is often useful to provide examples that utilize placeholders. In complex cases where you’re
trying to illustrate how a user might use feature, it is often useful to use actual tap/target/mapping names to illustrate
intent. But most commonly, especially for simple examples use common terms e.g. TAP
rather than extractor
or tap-something
.
We also have significant historic use of angle brackets as placeholders for user input in our documentation (and also help out). Which often looks like:
meltano elt <tap_name> <target_name>
In the context of something like a more conversational guide or other online docs this does help indicate that we expect the user to supply this input. However, our current use in help output is often ambigous when it comes to indicating whether this is a required item or optional item. So moving forward if you use this form in CLI help out you should still follow the documented conventions for indicating whether something is required:
# TAP and TARGET are upper case since they are required inputs
meltano run <TAP_NAME> <TARGET_NAME>
# MAPPER1 is wrapped in [] since its optional and a series
meltano <TAP> [MAPPER1 ...] <TARGET>
Prefer the term “deprecated” over “obsolete”. Commands that are deprecated should be marked as such in help text and in the meltano documentation. Deprecated commands should also explicitly emit a notice when they are used indicating their deprecation. Where appropriate the notice and help text should indicate the replacement command, or link to further information. If known, you should also document in what version you expect a command to be fully removed.
Prefer the term “preview” over “beta”. Commands that enable a preview feature should be marked as such in help text and in the meltano documentation. Where possible if not in the help output, then at least in the documentation, you should also document when the command is expected to graduate from preview status, and what if any shortcomings, defects, or missing functionality it currently has.