parser property

ArgParser parser
getter/setter pair

Command-line argument parser for custom build configuration.

This static parser defines all available command-line options and flags for custom build processes. It provides comprehensive configuration capabilities including binary type specification, build modes, custom arguments, and output path management.

Available Options

  • target (-t) - Main entry-point file for device execution
  • binary-type (-b) - Output binary format (apk, aab, ipa, etc.)
  • build-mode (-m) - Build optimization level (debug, profile, release)
  • flavor (-f) - Product flavor or build variant specification
  • arguments (-a) - Custom arguments for specialized build commands
  • dart-defines (-d) - Dart compilation define values
  • build-name (-n) - Human-readable version name
  • build-number (-N) - Numeric version identifier
  • output (-o) - Output directory path for build artifacts
  • pub (-p) - Flag to run pub get before building
  • dart-defines-file - File containing Dart define configurations

Default Values

  • binary-type: 'apk' - Default Android APK output
  • build-mode: 'release' - Optimized production builds
  • output: Custom output directory path from Files.customOutputDir
  • pub: true - Automatically run dependency resolution

Usage Examples

# Basic custom build
--binary-type aab --build-mode profile

# Advanced build with custom arguments
--binary-type ipa --arguments "--verbose --analyze-size" --flavor production

# Custom output location
--output ./custom-builds/ --build-name "v2.1.0" --build-number 42

Implementation

static ArgParser parser = ArgParser()
  ..addOption(
    'target',
    abbr: 't',
    help:
        'The main entry-point file of the application, as run on the device.',
  )
  ..addOption(
    'binary-type',
    abbr: 'b',
    help: 'Binary type (apk, aab, ipa, ios, macos, etc)',
    defaultsTo: 'apk',
  )
  ..addOption(
    'build-mode',
    abbr: 'm',
    help: 'Build mode (debug, profile, release)',
    defaultsTo: 'release',
  )
  ..addOption('flavor', abbr: 'f', help: 'Build flavor')
  ..addOption(
    'arguments',
    abbr: 'a',
    help: 'Custom arguments to pass to the build command',
  )
  ..addOption('dart-defines', abbr: 'd', help: 'Dart defines')
  ..addOption('build-name', abbr: 'n', help: 'Build name')
  ..addOption('build-number', abbr: 'N', help: 'Build number')
  ..addOption(
    'output',
    abbr: 'o',
    help: 'Output path for the build',
    defaultsTo: Files.customOutputDir.path,
  )
  ..addFlag(
    'pub',
    abbr: 'p',
    help: 'Run pub get before building',
    defaultsTo: true,
  )
  ..addOption('dart-defines-file', help: 'Dart defines file');