The Glean CLI tool
The Glean CLI tool (glean) can create and write data into databases,
perform a variety of admin tasks on databases, and also do one-off
queries.
The glean tool accepts all the common
options to specify how to connect to access
the databases.
The available commands are as follows:
glean listβ
List the available databases.
[DBNAME]
List only databases that matchDBNAME--format (tty|plain|json|compact-json)
Various different formats for the output. JSON is useful for processing and filtering the result in a script, e.g. usingjq.-v/--verbose
Show the full metadata associated with each database.--include-backups
Also list databases in backup storage (note: may be slow).
glean createβ
Create a new database.
--db NAME/INSTANCEor--db-name NAME --db-instance INSTANCE
Specifies the name and instance of the database--finish
Also mark the DB as complete--stacked DB
Create a stacked database on top ofDB.--property NAME=VALUE
Set properties when creating a DB--update-schema-for-stacked
When creating a stacked DB, the schema is taken from the base DB. This option specifies that the current schema should be used instead. When using this option, creation will fail if the current schema has a different definition for any predicate in the base DB schema; therefore predicates may only be added or removed relative to the base DB.FILE..
File(s) of facts to write into the database. Accepts JSON or compressed (zstd) JSONs. See Writing data to Glean.
The schema for the new DB is given by:
the property
glean.schema_idif specified, orif
--stackedor--incremental, then- if
--update-schema-for-stackedis specified, then the default schema (or the one given by the--schemaoption), - otherwise, the schema from the base DB.
- if
otherwise the default schema, or the one given by the
--schemaflag.
Note that when creating a stacked DB, it is an error if the schema does not agree with the schema in the base DB for any predicate that has facts. That is, you cannot change the schema in a stacked DB for existing facts in the base DB.
glean writeβ
Write facts to a database.
--db NAME/INSTANCEor--db-name NAME --db-instance INSTANCE
Specifies the name and instance of the databaseFILE..
File(s) of facts to write into the database. Accepts JSON or compressed (zstd) JSONs. See Writing data to Glean.--finish
Also mark the DB as complete
glean finishβ
Notify server that a database is complete.
--db NAME/INSTANCEor--db-name NAME --db-instance INSTANCE
Specifies the name and instance of the database
glean dumpβ
Dump the contents of the specified database into a file.
--db NAME/INSTANCEor--db-name NAME --db-instance INSTANCE
Specifies the name and instance of the databaseFILE
File to write the facts into
glean deleteβ
Delete a database.
--db NAME/INSTANCEor--db-name NAME --db-instance INSTANCE
Specifies the name and instance of the database
glean deriveβ
Derive and store a predicate. See Derived Predicates.
--page-bytes BYTES
Maximum number of bytes per page--page-facts FACTS
Maximum number of facts per pagePREDICATE
Predicates to derive
glean indexβ
Index some source code using one of the known indexers.
The form of the command in general is
glean index LANGUAGE DIR --db NAME/INSTANCE
There may also be additional options accepted for each LANGUAGE; try
glean index LANGUAGE --help to find out.
For information on each indexer, see Indexers.
glean queryβ
Execute an Angle query and print the results, or write them to a file.
--db NAME/INSTANCEor--db-name NAME
Specifies the database to query--page-bytes BYTES
Maximum number of bytes per page--page-facts FACTS
Maximum number of facts per page--expand
Fetch nested facts (slower)--limit FACTS
Maximum number of facts to query (default: no limit)-o,--output FILE
Output the facts to a file--stats FILE
Output stats to a file ('-' for stdout)--profile
Get full profiling information; use with--statsto include facts_searched--timeout MILLISECONDSOverride the default query timeoutQUERYquery to execute (@fileto read from file,-for stdin)--omit-resultsDon't print results; use with--statto get a count of results
glean restoreβ
Restore a database from backup.
LOCATOR
DB location, see:list-allin glean shell.
Alternatively the DB to restore can be specified by:
--db NAME/INSTANCEor--db-name NAMEand (--db-instance INSTANCEor--date YYY-MM-DDor--latest)
glean validateβ
Perform checks on the internal integrity of a database. This is for testing and debugging Glean itself.
a local database
--db NAME/INSTANCEor--db-name NAME --db-instance INSTANCE
Specifies the name and instance of the database--no-typecheck
Don't typecheck facts.--no-keys
Don't verify key uniqueness--limit N
Only validate the first N facts
glean validate-schemaβ
Validate a schema. Checks that a new schem does not modify any of the predicates in the existing schema, which could lead to problems.
FILE
Name of schema file
glean statsβ
Get fact counts and sizes. Like the :statistics command in the shell.
--db NAME/INSTANCEor--db-name NAME --db-instance INSTANCE
Specifies the name and instance of the database
glean unfinishβ
Unfinish a local database (turn it from complete to incomplete state). This is for testing and development and not for routine use: once a database is marked complete it could be replicated, so we shouldn't be modifying it.
--db NAME/INSTANCEor--db-name NAME --db-instance INSTANCE
Specifies the name and instance of the database