CLI Commands

Learn how to use the dart_shield CLI commands.

CLI Commands

dart_shield provides a command-line interface to manage security analysis and configuration.

Global Options

OptionAbbreviationDescription
--help-hPrint this usage information.
--versionPrint the current version.
--verbose-vEnable verbose logging.

init

Initialize dart_shield in the current project.

This command updates your analysis_options.yaml to include the dart_shield plugin and adds the default configuration section.

Usage

dart_shield init [arguments]

Options

OptionAbbreviationDescription
--force-fOverwrite existing dart_shield configuration if present in analysis_options.yaml.

Example

# Standard initialization
dart_shield init

# Force overwrite existing config
dart_shield init --force

analyze

Analyzes the project for possible security-related issues.

This command wraps dart analyze and additional internal analyzers to produce a security report.

Usage

dart_shield analyze [path] [arguments]
  • [path]: The directory to analyze. Defaults to current directory . if not specified.

Options

OptionAbbreviationDescriptionDefault
--reporter-rSelect the output format. Allowed: console, json, both.console
--onlyRun only specific analyzers (ignores config file settings). Allowed: code.
--excludeExclude specific analyzers. Allowed: code.

Examples

# Analyze current directory
dart_shield analyze

# Analyze specific folder with JSON output
dart_shield analyze lib/ --reporter json

# Analyze but exclude code analysis (e.g. if you only wanted other future analyzers)
dart_shield analyze --exclude code