Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions content/features/te-cli/te-cli-auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
uid: te-cli-auth
title: Authentication and Connections
author: Peer Grønnerup
updated: 2026-05-06
updated: 2026-06-11
applies_to:
products:
- product: Tabular Editor 2
Expand All @@ -24,7 +24,8 @@ The CLI supports the full Azure Identity credential chain:

| Method | When to use | `--auth` value |
| -- | -- | -- |
| Interactive browser | Local development - opens the system browser | `interactive` (default) |
| Automatic | Tries environment credentials, then cached or interactive browser login | `auto` (default) |
| Interactive browser | Local development - opens the system browser | `interactive` |
| Service principal (client secret) | Automation, CI/CD, headless / SSH / WSL | `spn` (with `-u / -p / -t`) or `env` |
| Service principal (certificate) | Automation with certificate-based auth | `spn` (with `-u / -t / --certificate`) |
| Environment variables | `AZURE_CLIENT_ID` / `AZURE_CLIENT_SECRET` / `AZURE_TENANT_ID` | `env` |
Expand Down Expand Up @@ -53,7 +54,7 @@ echo "$AZURE_CLIENT_SECRET" | te auth login -u "$AZURE_CLIENT_ID" -p - -t "$AZUR
te auth login -u "$AZURE_CLIENT_ID" -t "$AZURE_TENANT_ID" --certificate ./sp.pfx --certificate-password "$CERT_PASSWORD"

# Managed identity (Azure-hosted)
te auth login --identity
te auth login --identity # Alias: -I
```

After a successful service-principal login the CLI **caches the credentials** so every subsequent `te` command can acquire tokens silently - no need to re-pass `-u / -p / -t` or set the `AZURE_CLIENT_*` environment variables. Pass `--save=false` for a one-shot login that doesn't update the cache, or run `te auth logout` to clear it.
Expand Down Expand Up @@ -116,7 +117,7 @@ te connect
te connect --clear
```

Active-connection state is per-terminal-session: opening a new terminal starts fresh.
Active-connection state is per-terminal-session: opening a new terminal starts fresh. Inspect or clean up session state with [`te session`](xref:te-cli-commands#session).

### Workspace mode (`-w` / `--workspace`)

Expand Down
6 changes: 3 additions & 3 deletions content/features/te-cli/te-cli-automation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
uid: te-cli-automation
title: Automation and Scripting
author: Peer Grønnerup
updated: 2026-05-06
updated: 2026-06-11
applies_to:
products:
- product: Tabular Editor 2
Expand Down Expand Up @@ -54,8 +54,8 @@ Every `te` command exits with a predictable status code so callers can branch on
| Exit | Meaning |
| -- | -- |
| `0` | Success. |
| `1` | Generic failure - invalid arguments, command failed, validation errors, auth failure, BPA gate failed at severity ≥ error. |
| `2` | Used by `te diff` to indicate models differ (distinct from `0` identical and non-zero errors). |
| `1` | Generic failure - invalid arguments, command failed, validation errors, auth failure, BPA gate failed at severity ≥ error. For `te diff`: differences found (like the `diff`/`cmp` convention). |
| `2` | `te diff` only: an error occurred while comparing, so the difference status is unknown. |

Combine exit codes with `--ci <vsts\|github>` annotations and `--trx <file>` to surface rich failure information in CI - see @te-cli-cicd.

Expand Down
82 changes: 71 additions & 11 deletions content/features/te-cli/te-cli-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
uid: te-cli-commands
title: Command Reference
author: Peer Grønnerup
updated: 2026-05-12
updated: 2026-06-11
applies_to:
products:
- product: Tabular Editor 2
Expand Down Expand Up @@ -134,6 +134,8 @@ These flags are available on every command and can be used before or after the s
| `--non-interactive` | Disable all interactive prompts. Fail with an actionable error if required input is missing. |
| `--debug` | Enable debug logging to stderr (connection strings, auth flow, timing). |

`te --version` prints the CLI version and exits.

For commands that read a model, the resolution order is:

positional `<model>` argument → `--model` global flag → `--server`/`--database` (remote) → active connection from `te connect` → `--recent`.
Expand Down Expand Up @@ -185,10 +187,22 @@ te open ./my-model

### init

Create a new empty semantic model at the given path.
Create a new empty semantic model at the given path. Defaults to a TMDL model in `PowerBI` compatibility mode at compatibility level 1702.

`te init` accepts:

- `<output-path>` - positional argument: directory to create the model in (omit to use the global `--model` path).
- `--compatibility-mode <mode>` - `PowerBI` (default) or `AnalysisServices`.
- `--compatibility-level <N>` (alias `--compat`) - compatibility level. Defaults to `1702` when the mode is `PowerBI`, `1500` otherwise. See @update-compatibility-level.
- `--name <name>` - model/database name (default: the directory name).
- `--serialization <fmt>` - `tmdl` (default), `bim`, `te-folder`, `pbip`.
- `--force` - replace any existing file or directory at the target path.

```bash
te init ./new-model
te init ./new-model # TMDL, PowerBI mode, compat 1702
te init ./new-model --serialization bim # Single-file BIM model
te init ./as-model --compatibility-mode AnalysisServices # AS model, compat 1500
te init ./existing-dir --force # Overwrite non-empty directory
```

## Model editing
Expand Down Expand Up @@ -324,7 +338,7 @@ Get properties of a model object. Takes a `<path>`.
`te get` accepts:

- `-q, --query <property>` - fetch a single property (e.g. `expression`, `formatString`).
- `-t, --type <kind>` - disambiguate when the path matches multiple table-children (e.g. a column and a hierarchy with the same name). Values: `Measure`, `Column`, `CalculatedColumn`, `Hierarchy`, `Calendar`, `Partition`, `CalculationItem`.
- `-t, --type <kind>` - disambiguate when the path matches multiple table-children (e.g., a column and a hierarchy with the same name). Values: `Measure`, `Column`, `CalculatedColumn`, `Hierarchy`, `Calendar`, `Partition`, `CalculationItem`.
- `--output-format tmsl` (alias `bim`) - emit the resolved object as TMSL/BIM JSON.
- `--output-format tmdl` - emit the resolved object as TMDL (named objects only).

Expand Down Expand Up @@ -374,12 +388,18 @@ Analyze an object's upstream and downstream dependencies, or surface unused obje

`te deps` accepts:

- `--upstream` - show only upstream dependencies (what this object uses).
- `--downstream` - show only downstream dependents (what uses this object).
- `--deep` - show the recursive dependency tree instead of direct dependencies only.
- `--max-depth <N>` - maximum depth for `--deep` traversal (default: `10`).
- `-t, --type <kind>` - disambiguate when the path matches multiple table-children (e.g., a column and a hierarchy with the same name).
- `--unused` - list measures, calculated columns, and **all data columns** that no DAX references and that aren't used in any relationship, hierarchy level, sort-by, variation, AlternateOf base, or calendar time role. Each result shows `(hidden)` in text mode and an `isHidden` field in JSON.
- `--hidden` - narrow `--unused` to hidden objects only. Hidden, unused objects are the safest prune candidates because nothing user-facing depends on them.

```bash
te deps Sales/Revenue # Upstream + downstream for one object
te deps "'Sales'[Revenue]" # DAX form is accepted everywhere a <path> is
te deps Sales/Revenue --downstream --deep # Everything that depends on Revenue, recursively
te deps --unused # All unused measures and columns
te deps --unused --hidden # Only hidden, unused objects
```
Expand All @@ -394,10 +414,16 @@ Validate model expressions, schema integrity, and TOM errors.

- `--ci <fmt>` - emit CI annotations to stderr: `vsts` or `github`.
- `--trx <path>` - write results as a VSTEST `.trx` file.
- `--errors-only` - shorthand for `--no-warnings --no-antipatterns`: only show errors.
- `--no-warnings` - hide warnings from the semantic analyzer.
- `--no-antipatterns` - hide anti-pattern suggestions (DAX best-practice hints).
- `--server-only` - only show errors reported by the connected server; skip local semantic analysis.
- `--no-multiline` - collapse multi-line cell content (error messages, expressions) to a single line. Text output only.

```bash
te validate ./model
te validate --ci github --trx results.trx
te validate --errors-only # Hide warnings and anti-pattern hints
```

### bpa run
Expand Down Expand Up @@ -545,6 +571,8 @@ Analyze VertiPaq storage statistics.
`te vertipaq` accepts:

- `--columns`, `--relationships`, `--partitions`, `--all`.
- `--detail` - show expanded columns (data/dict/hierarchy size breakdown, encoding, segments).
- `--fields <list>` - comma-separated fields to display (e.g., `--fields name,card,size,%tbl,%db,bar`). Available fields vary by view.
- `--export <file.vpax>` - export VertiPaq stats to a `.vpax` file for offline analysis.
- `--import <file.vpax>` - load a previously exported `.vpax` file and analyze it offline.
- `--obfuscate` - obfuscate names and expressions in exported VPAX.
Expand All @@ -565,7 +593,11 @@ Format DAX or M/Power Query expressions.

- `-e, --expression <text>` - format a single inline expression.
- `-p, --path <path>` - format a specific measure/column.
- `--lang <dax|m>` - default `dax`.
- `-t, --type <kind>` - disambiguate when the path matches multiple table-children.
- `--lang <lang>` - expression language: `dax` (default) or `m`/`pq` for Power Query.
- `--semicolons` - use semicolons as list separators (European locale).
- `--long` - use long format (more line breaks). Default is short.
- `--no-space-after-function` - skip the space after function names.
- `--save` / `--save-to` - persist formatted expressions.

```bash
Expand Down Expand Up @@ -604,7 +636,7 @@ Execute one or more C# scripts against a semantic model. The CLI uses the same s
- `-S, --script <file>` - `.cs` / `.csx` file (repeatable).
- `-e, --expression <code>` - inline C# (use `-` for stdin).
- `--save` / `--save-to` / `--serialization`.
- `--dry-run`, `--timeout <seconds>`.
- `--dry-run` - compile the script(s) and report errors without executing them.

```bash
te script --script fix.cs --save
Expand All @@ -615,7 +647,7 @@ echo "Info(Model.Name);" | te script -e -
> [!IMPORTANT]
> Two behavioral details to know if you're porting an older script:
>
> - **No interactive selection in CLI scripts.** The TE3 Desktop helpers `SelectMeasure()`, `SelectTable()`, `SelectColumn()`, `SelectObject()`, and `SelectObjects()` throw `NotSupportedException` when called from `te script` - the CLI has no UI to pop up. Pre-resolve the object(s) outside the script and pass them in, or wrap the call in `try/catch` if the script is shared with TE3.
> - **No interactive selection in CLI scripts.** The TE3 Desktop helpers `SelectMeasure()`, `SelectTable()`, `SelectColumn()`, `SelectObject()`, and `SelectObjects()` throw `NotSupportedException` when called from `te script` - the CLI has no UI to pop up. Pre-resolve the object(s) outside the script and pass them in via environment variables or stdin, or wrap the call in `try/catch` if the script is shared with TE3.
> - **Default `using` directives match TE3 Desktop.** Scripts that use `DataTable`, `File`, `StringBuilder`, or `Regex` must include the corresponding `using System.Data;` / `using System.IO;` / `using System.Text;` / `using System.Text.RegularExpressions;` directive explicitly.

> [!NOTE]
Expand Down Expand Up @@ -749,7 +781,7 @@ Manage incremental refresh policies on tables.
te incremental-refresh show <table>
```

Additional subcommands (`set`, `remove`, `apply`) are documented via `te incremental-refresh --help`.
Additional subcommands (`set`, `rm`, `apply`) are documented via `te incremental-refresh --help`.

## Testing

Expand Down Expand Up @@ -801,6 +833,7 @@ Pair a primary source with a secondary target so every subsequent `--save` mirro
- `te connect <ws> <model> -w ./src` - primary is remote; `./src` receives an initial TMDL export and mirrors every save.
- `te connect ./src -w <ws> <model>` - primary is local; an initial deploy pushes the model to the workspace, and subsequent saves re-deploy automatically.
- `--workspace-format <bim|tmdl>` - choose the on-disk format when mirroring to a folder/file (e.g., `-w ./model.bim` infers BIM).
- `--workspace-auth <method>` - auth method for a remote workspace target when the primary is local. Defaults to `--auth` if set, else `auto`.
- `--force` - required when the target already exists (non-empty folder, existing database). Without it, `te connect` shows an interactive `y/n` prompt with `n` as the safe default.

Once active, `te set --save`, `te rm --save`, `te script --save`, etc. all dual-save transparently. Save order is always **local first, then remote** so the on-disk copy reflects the latest user change even if the server push fails. Clear the mirror with `te connect --clear`.
Expand Down Expand Up @@ -859,23 +892,50 @@ te interactive -s MyWorkspace -d MyModel # Start with a remote model

Quoting and DAX-style references work the same as outside the session - see the [Object paths](#object-paths) section above and @te-cli-interactive for details on bracket-aware argv splitting inside the REPL.

### session

Show or manage the current terminal session. The CLI keeps per-terminal state (active connection, active profile, active test suite) in a session file, isolated per shell process. Set the `TE_SESSION` environment variable to share one named session across shells.

Subcommands:

| Subcommand | Purpose |
| -- | -- |
| `show` | Show current session details (ID, file path, active state). Default when no subcommand is given. |
| `list` | List all session files. |
| `clear` | Clear active state for the current session. |
| `prune` | Delete session files whose shell process is no longer running. |

`te session prune` accepts:

- `--all` - also remove sessions with live shells and named (`TE_SESSION`) sessions. The current session is always kept.
- `--dry-run` - show what would be removed without doing it.

```bash
te session # Show current session details
te session list # List all session files
te session clear # Clear active state for this session
te session prune # Remove sessions whose shell is dead
te session prune --all --dry-run # Preview a full cleanup
```

### completion

Generate a shell completion script. See @te-cli-install.
Generate a shell completion script for `bash`, `zsh`, `powershell` (alias `pwsh`) or `fish`. See @te-cli-install.

```bash
te completion bash
te completion zsh
te completion pwsh
te completion fish
```

## Exit codes

| Exit | Meaning |
| -- | -- |
| `0` | Success. |
| `1` | Generic failure (invalid arguments, command failed, validation errors, auth failure, BPA gate failed at severity ≥ error). |
| `2` | Non-zero diff (`te diff`) - models differ. |
| `1` | Generic failure (invalid arguments, command failed, validation errors, auth failure, BPA gate failed at severity ≥ error). For `te diff`: differences found. |
| `2` | `te diff` only: an error occurred while comparing, so the difference status is unknown. |

For fine-grained control in CI pipelines, combine exit codes with `--ci <vsts/github>` annotations and `--trx` results files - see @te-cli-cicd.

Expand Down
4 changes: 2 additions & 2 deletions content/features/te-cli/te-cli-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
uid: te-cli-config
title: Custom Configuration
author: Peer Grønnerup
updated: 2026-04-20
updated: 2026-06-11
applies_to:
products:
- product: Tabular Editor 2
Expand Down Expand Up @@ -247,7 +247,7 @@ Use the following CLI-specific environment variables for paths, behavior, and di
| `TE_DEBUG` | Set to `1` to enable debug logging globally (same as `--debug` or `debug: true` in config). |
| `NO_SPINNER` | Set to `1` or `true` to disable animated progress indicators (alternative to `spinner: false` in config). |
| `CI` | Auto-detected. When `1` or `true`, the CLI disables the spinner and switches to plain output. Most CI runners set this automatically. |
| `TE_SESSION` | Override the per-terminal session ID used for active-connection state. Useful for running multiple isolated CLI sessions inside the same shell, e.g. in parallel CI matrix jobs. |
| `TE_SESSION` | Override the per-terminal session ID used for active-connection state. Useful for running multiple isolated CLI sessions inside the same shell, e.g. in parallel CI matrix jobs. Inspect and manage sessions with [`te session`](xref:te-cli-commands#session). |
| `TE_COMPAT` | Set to `te2` to force TE2-compatibility mode - see @te-cli-migrate. |

## Related pages
Expand Down
10 changes: 8 additions & 2 deletions content/features/te-cli/te-cli-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
uid: te-cli-install
title: Installation and Setup
author: Peer Grønnerup
updated: 2026-05-06
updated: 2026-06-11
applies_to:
products:
- product: Tabular Editor 2
Expand Down Expand Up @@ -131,7 +131,7 @@ te config set hidePreviewNotice true

## Shell completion

The CLI provides tab-completion scripts for **Bash**, **Zsh**, and **PowerShell**. Pick the block that matches your shell — each one installs the completion persistently for new shell sessions.
The CLI provides tab-completion scripts for **Bash**, **Zsh**, **PowerShell** and **Fish**. Pick the block that matches your shell — each one installs the completion persistently for new shell sessions.

### Bash (macOS/Linux)

Expand All @@ -154,6 +154,12 @@ echo 'fpath=(~/.zfunc $fpath); autoload -U compinit; compinit' >> ~/.zshrc
Add-Content $PROFILE 'te completion pwsh | Out-String | Invoke-Expression'
```

### Fish (macOS/Linux)

```bash
te completion fish > ~/.config/fish/completions/te.fish
```

Open a new shell session for completion to take effect.

Completion covers subcommands, global flags, and model paths (where tab-completion against the filesystem is meaningful).
Expand Down
Loading
Loading