AFCommandContext class

The primary runtime context passed to a command during execution.

Constructors

AFCommandContext({required List<AFCommandContext> parents, required AFCommandOutput output, required AFCommandAppExtensionContext definitions, required AFCodeGenerator generator, required ArgResults arguments, required String packagePath, required AFSourceTemplateInsertions coreInsertions, required Map<String, String> globalTemplateOverrides})
AFCommandContext.withArguments({required AFCommandAppExtensionContext definitions, required AFCommandOutput output, required AFCodeGenerator generator, required String packagePath, required AFArgs arguments, required AFSourceTemplateInsertions coreInsertions, List<AFCommandContext>? parents, required Map<String, String>? globalTemplateOverrides})
factory

Properties

arguments → ArgResults
The arguments to the command, but use parseArguments for a higher level interface.
final
commandArgCount ↔ int
getter/setter pair
coreInsertions ↔ AFSourceTemplateInsertions
The baseline set of code insertions for this context.
getter/setter pair
definitions → AFCommandAppExtensionContext
Definitions, notablly of commands themselves, and of registered source code templates.
final
generator → AFCodeGenerator
The primary interface for code generation.
final
globalTemplateOverrides ↔ Map<String, String>
getter/setter pair
hashCode → int
The hash code for this object.
no setterinherited
isExportTemplates → bool
Returns true if the user specified the --export-templates flag.
no setter
isForceOverwrite → bool
True if force override argument was specified.
no setter
isRootCommand → bool
no setter
out → AFCommandOutput
no setter
output → AFCommandOutput
A utility for writing command line output.
final
packagePath ↔ String
getter/setter pair
parents → List<AFCommandContext>
A list of parent commands, if this command was executed via executeSubCommand
final
rawArgs → List<String>
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

createDeclareId(String id) → void
Given a fully specified id, like XXXScreenID.myScreen, creates an entry for it in the id file.
createFile(List<String> projectPath, AFFileSourceTemplate template, {AFSourceTemplateInsertions? extend, Map<AFSourceTemplateInsertion, Object>? insertions}) → AFGeneratedFile
Creates a file from the specified template at the specified path, with the specified insertions replaced.
createSnippet(Object source, {AFSourceTemplateInsertions? extend, Map<AFSourceTemplateInsertion, Object>? insertions}) → AFCodeBuffer
Given a snippet and a set of insertions, returns a code buffer with the insertions replaced.
executeSubCommand(String cmd, AFSourceTemplateInsertions? insertions) → Future<void>
Used to execute a subcommand.
findArgument(String key) → Object?
It is bettter to use AFCommandContext.parseArguments.
findEmbeddedTemplateFile(List<String> path) → AFFileSourceTemplate?
Finds a file template that is part of the AFTemplateRegistry
findEmbeddedTemplateSnippet(List<String> path) → AFSnippetSourceTemplate?
Finds a snippet template that is part of the AFTemplateRegistry
findOverrideTemplate(List<String> sourceTemplate) → List<String>
Given a template path, returns an override template path if the --override-templates flag was specified.
loadPubspec({String? packageName}) → Pubspec
Loads the pubspec file for the current project.
memberVariables(AFCommandContext context, AFCommandArgumentsParsed args, String mainType, {bool isAugment = false, bool? isIntIdOverride}) → AFMemberVariableTemplates?
Utility for parsing the --member-variables and --resolve-variables flags, if present.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
parseArguments({required AFCommand command, int unnamedCount = -1, required Map<String, String?> named}) → AFCommandArgumentsParsed
Used to parse the command's arguments at a high-level.
readProjectStyle(List<String> projectPath, {AFSourceTemplateInsertions? extend, Map<AFSourceTemplateInsertion, Object>? insertions}) → AFGeneratedFile
Reads the specified project sytle, replacing the specified insertions.
reviseAddCoreInsertions(Map<AFSourceTemplateInsertion, Object> revisedInsertions) → AFCommandContext
reviseWithArguments({required AFSourceTemplateInsertions insertions, required AFArgs arguments}) → AFCommandContext
Used to create a new subcommand with a revised set of arguments.
setCommandArgCount(int count) → void
setCoreInsertions(AFSourceTemplateInsertions insertions, {required String packagePath}) → void
setProjectStyle(String projectStyle) → void
setProjectStyleGlobalOverrides(String templateOverrides) → void
Used to provide source template overrides at a global level.
startCommand() → void
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

consolidateProjectStyleLines(AFCommandContext context, List<String> rawLines) → List<String>
Utility which allows project styles to contain a + syntax that spreads a command out over multiple lines.
findProjectStyleGlobalOverrides(AFCommandContext context, List<String> rawLines) → String
Used to provide source templates overrides at a global level.
simplifyProjectStyleCommand(String line) → String
writeConvertingIntIdMessage(AFCommandContext context) → void

Constants

pullDownArguments → const List<String>