@@ -42,6 +42,9 @@ typedef MasonGeneratorFromBundle = Future<MasonGenerator> Function(MasonBundle);
4242///
4343/// For sub commands that receive a publishable flag, sub classes must mix with
4444/// [Publishable] .
45+ ///
46+ /// For sub commands that receive a workspace flag, sub classes must mix with
47+ /// [Workspace] .
4548abstract class CreateSubCommand extends Command <int > {
4649 /// {@macro create_subcommand}
4750 CreateSubCommand ({
@@ -99,6 +102,16 @@ abstract class CreateSubCommand extends Command<int> {
99102 help: 'Whether the generated project is intended to be published.' ,
100103 );
101104 }
105+
106+ if (this is Workspace ) {
107+ argParser.addFlag (
108+ 'workspace' ,
109+ aliases: ['ws' ],
110+ help:
111+ 'Whether the generated project should resolve its dependencies '
112+ 'from a parent Pub workspace.' ,
113+ );
114+ }
102115 }
103116
104117 /// The logger user to notify the user of the command's progress.
@@ -237,6 +250,7 @@ abstract class CreateSubCommand extends Command<int> {
237250 ///
238251 /// For subcommands that mix with [OrgName] , it includes 'org_name'.
239252 /// For subcommands that mix with [Publishable] , it includes 'publishable'.
253+ /// For subcommands that mix with [Workspace] , it includes 'workspace'.
240254 @mustCallSuper
241255 Map <String , dynamic > getTemplateVars () {
242256 final projectName = this .projectName;
@@ -247,6 +261,7 @@ abstract class CreateSubCommand extends Command<int> {
247261 'description' : projectDescription,
248262 if (this is OrgName ) 'org_name' : (this as OrgName ).orgName,
249263 if (this is Publishable ) 'publishable' : (this as Publishable ).publishable,
264+ if (this is Workspace ) 'workspace' : (this as Workspace ).workspace,
250265 };
251266 }
252267}
@@ -318,3 +333,12 @@ mixin Publishable on CreateSubCommand {
318333 /// Gets the publishable flag.
319334 bool get publishable => argResults['publishable' ] as bool ? ?? false ;
320335}
336+
337+ /// Mixin for [CreateSubCommand] subclasses that receives the workspace flag.
338+ ///
339+ /// Takes care of parsing it from [argResults] and pass it
340+ /// to the brick generator.
341+ mixin Workspace on CreateSubCommand {
342+ /// Gets the workspace flag.
343+ bool get workspace => argResults['workspace' ] as bool ? ?? false ;
344+ }
0 commit comments