moon query command provides a suite of sub-commands for querying information about your moon
workspace using a powerful query language. All query commands output JSON
for easy integration with other tools.
Sub-commands
moon query projects
Query for projects within the project graph. Results can be filtered using query statements or
option flags.
Output structure
Arguments
[query]- An optional query statement to filter projects. When provided, all filter options are ignored.
Options
Affected:--affected- Filter projects that have been affected by changed files--downstream- Include downstream dependents of queried projects. Supports “none” (default), “direct”, “deep”--upstream- Include upstream dependencies of queried projects. Supports “none” (default), “direct”, “deep”
--alias <regex>- Filter projects that match this alias--id <regex>- Filter projects that match this ID/name--language <regex>- Filter projects of this programming language--layer <regex>- Filter projects of this layer--source <regex>- Filter projects that match this source path--stack <regex>- Filter projects of this tech stack--tags <regex>- Filter projects that have the following tags--tasks <regex>- Filter projects that have the following tasks
moon query tasks
Query for tasks within the task graph, grouped by project. Results can be filtered using query
statements or option flags.
Output structure
Arguments
[query]- An optional query statement to filter tasks. When provided, all filter options are ignored.
Options
Affected:--affected- Filter tasks that have been affected by changed files--downstream- Include downstream dependents of queried tasks. Supports “none” (default), “direct”, “deep”--upstream- Include upstream dependencies of queried tasks. Supports “none”, “direct”, “deep” (default)
--command <regex>- Filter tasks that match this command--id <regex>- Filter tasks that match this ID--project <regex>- Filter tasks that belong to this project--script <regex>- Filter tasks that match this script--toolchain <regex>- Filter tasks of this toolchain--type <regex>- Filter tasks of this type
moon query affected
Query for affected projects and tasks based on changed files between revisions.
Arguments
Refer to the query affected documentation for detailed information.moon query changed-files
Query for changed files between VCS revisions.
Arguments
Refer to the query changed-files documentation for detailed information.Query language syntax
moon provides a powerful query language for filtering projects and tasks. The query language supports the following operators and patterns:Operators
=- Exact match~- Pattern match (regex)!=- Not equal!~- Not pattern match
Field queries
Combining queries
Use&& (AND) and || (OR) to combine multiple conditions:
Arrays and lists
Use square brackets to match against arrays:Configuration
Examples
Finding affected projects
Use query commands with--affected to find what changed:
Piping to other tools
Since query commands output JSON, you can pipe results to tools likejq: