cli
napt.cli
Command-line interface for NAPT.
Commands:
init: Initialize a new NAPT project
validate: Validate recipe syntax and configuration
discover: Discover latest version and download installer
build: Build PSADT package from recipe
package: Create .intunewin package for Intune (recipe-based)
upload: Upload .intunewin package to Microsoft Intune
auth: Sign in to Microsoft Graph and inspect credentials
promote: Plan and apply deployment ring promotion
status: Show deployment state across all apps
Each command lives in its own module named after it -- napt/cli/validate.py
owns napt validate -- holding the command's cmd_* handlers and a
register(subparsers) hook that adds its parser. napt/cli/main.py
assembles the top-level parser, calls each command's register, and
dispatches to the selected handler.
Exit Codes:
- 0: Success
- 1: Error (configuration, download, or validation failure)
Note
The CLI uses argparse for command parsing (stdlib, zero dependencies). Verbose mode shows full tracebacks on errors for debugging. Debug mode implies verbose mode and shows detailed configuration dumps.
napt.cli.main
CLI entry point: parser assembly and dispatch.
Builds the top-level napt argument parser, calls each command
module's register hook to add its subparser, and dispatches to the
selected command's handler. Registered as the napt console script in
pyproject.toml.
main
Main entry point for the napt CLI.
This function is registered as the 'napt' console script in pyproject.toml.
Source code in napt/cli/main.py
napt.cli.auth
The napt auth command.
Manages the credential NAPT uses for Intune through the login,
logout, status, and setup subcommands.
cmd_auth_login
Handler for 'napt auth login' command.
Signs in interactively through the OS broker or the browser and caches the session so later commands authenticate silently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args
|
Namespace
|
Parsed command-line arguments containing optional client and tenant IDs and the --no-broker flag. |
required |
Returns:
| Type | Description |
|---|---|
int
|
Exit code (0 for success, 1 for failure). |
Source code in napt/cli/auth.py
cmd_auth_logout
Handler for 'napt auth logout' command.
Removes the active tenant's cached session, or every tenant's with --all. Client and tenant IDs are kept for the next login.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args
|
Namespace
|
Parsed command-line arguments containing the --all flag and debug flags. |
required |
Returns:
| Type | Description |
|---|---|
int
|
Exit code (0 for success, 1 for failure). |
Source code in napt/cli/auth.py
cmd_auth_status
Handler for 'napt auth status' command.
Shows which credential NAPT would use right now -- the same resolution 'napt upload' performs -- and flags missing Graph permissions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args
|
Namespace
|
Parsed command-line arguments containing debug flags. |
required |
Returns:
| Type | Description |
|---|---|
int
|
Exit code (0 when a credential is available, 1 otherwise). |
Source code in napt/cli/auth.py
cmd_auth_setup
Handler for 'napt auth setup' command.
Creates or completes the NAPT app registration in a tenant through Microsoft Graph, or with --print-only prints the equivalent portal checklist without signing in.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args
|
Namespace
|
Parsed command-line arguments containing the tenant ID, optional name, client ID, federated credential settings, and flags. |
required |
Returns:
| Type | Description |
|---|---|
int
|
Exit code (0 for success, 1 for failure). |
Source code in napt/cli/auth.py
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | |
register
Registers the 'auth' command parser and its subcommands.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subparsers
|
_SubParsersAction
|
The CLI's subparsers action to add the command to. |
required |
Source code in napt/cli/auth.py
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 | |
napt.cli.build
The napt build command.
Creates a PSADT deployment package from a recipe and a downloaded installer.
cmd_build
Handler for 'napt build' command.
Builds a PSADT package from a recipe and downloaded installer. This command loads the recipe configuration, finds the downloaded installer, extracts version from the installer file (filesystem is truth), downloads/caches the specified PSADT release, creates build directory structure, copies PSADT files pristine from cache, generates Invoke-AppDeployToolkit.ps1 with recipe values, copies installer to Files/ directory, and applies custom branding.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args
|
Namespace
|
Parsed command-line arguments containing recipe path, downloads directory, output directory, and flags. |
required |
Returns:
| Type | Description |
|---|---|
int
|
Exit code (0 for success, 1 for failure). |
Note
Creates build directory structure. Downloads PSADT release if not cached. Generates Invoke-AppDeployToolkit.ps1. Copies files to build directory. Prints progress and results to stdout.
Source code in napt/cli/build.py
register
Registers the 'build' command parser.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subparsers
|
_SubParsersAction
|
The CLI's subparsers action to add the command to. |
required |
Source code in napt/cli/build.py
napt.cli.discover
The napt discover command.
Finds the latest version of an application with the configured discovery strategy and downloads the installer.
cmd_discover
Handler for 'napt discover' command.
Discovers the latest version of an application by querying the source and downloading the installer. This command validates the recipe YAML, uses the configured discovery strategy to find the latest version, downloads the installer (or reuses the one an earlier run downloaded), extracts version information, and records the release as a pending publication candidate in deployment state when it differs from the published version.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args
|
Namespace
|
Parsed command-line arguments containing recipe path, output directory, deployment state directory, and flags. |
required |
Returns:
| Type | Description |
|---|---|
int
|
Exit code (0 for success, 1 for failure). |
Note
Downloads installer file to output_dir (or reuses an earlier download). Updates the app's deployment state file with the pending release. Prints progress and results to stdout. Prints errors with optional traceback if verbose/debug.
Source code in napt/cli/discover.py
register
Registers the 'discover' command parser.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subparsers
|
_SubParsersAction
|
The CLI's subparsers action to add the command to. |
required |
Source code in napt/cli/discover.py
napt.cli.init
The napt init command.
Creates a new NAPT project structure with default configuration.
cmd_init
Handler for 'napt init' command.
Initializes a new NAPT project by creating the directory structure and default configuration files. This command creates the recipes/ directory, defaults/ directory with org.yaml template, defaults/vendors/ directory, and state/deployment/ directory for per-app deployment state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args
|
Namespace
|
Parsed command-line arguments containing directory path, force flag, and debug flags. |
required |
Returns:
| Type | Description |
|---|---|
int
|
Exit code (0 for success, 1 for failure). |
Note
By default, existing files are skipped (not overwritten). Use --force to backup existing files and create fresh ones.
Source code in napt/cli/init.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | |
register
Registers the 'init' command parser.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subparsers
|
_SubParsersAction
|
The CLI's subparsers action to add the command to. |
required |
Source code in napt/cli/init.py
napt.cli.package
The napt package command.
Packages a PSADT build into a .intunewin file for Intune deployment.
cmd_package
Handler for 'napt package' command.
Creates a .intunewin package from a PSADT build for the given recipe. Infers the build directory from the recipe's app ID, removes any previously packaged version (single-slot), copies detection scripts alongside the .intunewin file so 'napt upload' is self-contained, and optionally cleans the source build directory after packaging.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args
|
Namespace
|
Parsed command-line arguments containing recipe path, version, output directory, clean flag, and debug flags. |
required |
Returns:
| Type | Description |
|---|---|
int
|
Exit code (0 for success, 1 for failure). |
Note
Without --version, picks the most recently modified build. Run 'napt build' before 'napt package'. Downloads IntuneWinAppUtil.exe if not cached. Optionally removes the build directory if --clean-source.
Source code in napt/cli/package.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |
register
Registers the 'package' command parser.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subparsers
|
_SubParsersAction
|
The CLI's subparsers action to add the command to. |
required |
Source code in napt/cli/package.py
napt.cli.promote
The napt promote command.
Plans and applies ring-based promotion of published apps through the
plan and apply subcommands.
cmd_promote_plan
Handler for 'napt promote plan' command.
Computes promotion actions for all recipes (or one recipe) as a pure function of deployment state, configuration, and the clock, and writes one plan file per app with work. Read-only with respect to Intune, and — unless --reconcile recovers a lost publication writeback first — to deployment state; an app's stale plan file is removed when none of its actions remain eligible.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args
|
Namespace
|
Parsed command-line arguments containing the recipes path, state directory, and flags. |
required |
Returns:
| Type | Description |
|---|---|
int
|
Exit code (0 for success — with or without planned actions, |
int
|
1 for failure). |
Source code in napt/cli/promote.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | |
cmd_promote_apply
Handler for 'napt promote apply' command.
Executes promotion plans against Intune: assigns install entries, promotes releases through rings, displaces the older releases they replace, and retires them per the retention policy. Consumes each per-app plan file after its app applies fully; otherwise plans fresh and applies immediately. One app's failure keeps its plan file for retry and never blocks the others, and stale or already-applied actions are skipped with a warning, so re-running after a partial failure is safe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args
|
Namespace
|
Parsed command-line arguments containing the recipes path, state directory, plan file, and flags. |
required |
Returns:
| Type | Description |
|---|---|
int
|
Exit code (0 for success — including nothing to apply, |
int
|
1 for failure, including any app whose plan failed to apply). |
Source code in napt/cli/promote.py
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | |
register
Registers the 'promote' command parser and its subcommands.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subparsers
|
_SubParsersAction
|
The CLI's subparsers action to add the command to. |
required |
Source code in napt/cli/promote.py
315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 | |
napt.cli.status
The napt status command.
Aggregates per-app deployment state into one view: published version, pending release, and ring positions.
cmd_status
Handler for 'napt status' command.
Aggregates all per-app deployment state files into one view: the published version, pending release, and which version holds each ring.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args
|
Namespace
|
Parsed command-line arguments containing the state directory, output format, and flags. |
required |
Returns:
| Type | Description |
|---|---|
int
|
Exit code (0 for success, 1 for failure). |
Source code in napt/cli/status.py
register
Registers the 'status' command parser.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subparsers
|
_SubParsersAction
|
The CLI's subparsers action to add the command to. |
required |
Source code in napt/cli/status.py
napt.cli.upload
The napt upload command.
Uploads the packaged .intunewin file for a recipe to Microsoft Intune via the Graph API.
cmd_upload
Handler for 'napt upload' command.
Uploads the .intunewin package for a recipe to Microsoft Intune via the Graph API. Infers the package path from the recipe's app ID. Authentication uses service principal / OIDC environment variables when set, otherwise the session saved by 'napt auth login'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args
|
Namespace
|
Parsed command-line arguments containing recipe path and debug flags. |
required |
Returns:
| Type | Description |
|---|---|
int
|
Exit code (0 for success, 1 for failure). |
Note
Run 'napt package' before this command to create the .intunewin file. Re-running an upload adopts existing NAPT-stamped apps instead of creating duplicates; --force re-sends metadata and content to them. Developers: run 'napt auth login' once. CI/CD: set AZURE_CLIENT_ID, AZURE_TENANT_ID and AZURE_CLIENT_SECRET, or use OIDC federation.
Source code in napt/cli/upload.py
register
Registers the 'upload' command parser.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subparsers
|
_SubParsersAction
|
The CLI's subparsers action to add the command to. |
required |
Source code in napt/cli/upload.py
napt.cli.validate
The napt validate command.
Checks recipe YAML for syntax errors and configuration issues without downloading files or making network calls.
cmd_validate
Handler for 'napt validate' command.
Validates recipe syntax and configuration without downloading files or making network calls. This is useful for quick feedback during recipe development and for CI/CD pre-checks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args
|
Namespace
|
Parsed command-line arguments containing recipe path and verbose flag. |
required |
Returns:
| Type | Description |
|---|---|
int
|
Exit code (0 for valid recipe, 1 for invalid). |
Note
Prints validation results, errors, and warnings to stdout.
Source code in napt/cli/validate.py
register
Registers the 'validate' command parser.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subparsers
|
_SubParsersAction
|
The CLI's subparsers action to add the command to. |
required |