@@ -43,6 +43,9 @@ typedef MasonGeneratorFromBundle = Future<MasonGenerator> Function(MasonBundle);
4343///
4444/// For sub commands that receive a publishable flag, sub classes must mix with
4545/// [Publishable] .
46+ ///
47+ /// For sub commands that receive a workspace flag, sub classes must mix with
48+ /// [Workspace] .
4649abstract class CreateSubCommand extends Command <int > {
4750 /// {@macro create_subcommand}
4851 CreateSubCommand ({
@@ -100,6 +103,16 @@ abstract class CreateSubCommand extends Command<int> {
100103 help: 'Whether the generated project is intended to be published.' ,
101104 );
102105 }
106+
107+ if (this is Workspace ) {
108+ argParser.addFlag (
109+ 'workspace' ,
110+ aliases: ['ws' ],
111+ help:
112+ 'Whether the generated project should resolve its dependencies '
113+ 'from a parent Pub workspace.' ,
114+ );
115+ }
103116 }
104117
105118 /// The logger user to notify the user of the command's progress.
@@ -262,6 +275,7 @@ abstract class CreateSubCommand extends Command<int> {
262275 ///
263276 /// For subcommands that mix with [OrgName] , it includes 'org_name'.
264277 /// For subcommands that mix with [Publishable] , it includes 'publishable'.
278+ /// For subcommands that mix with [Workspace] , it includes 'workspace'.
265279 @mustCallSuper
266280 Map <String , dynamic > getTemplateVars () {
267281 final projectName = this .projectName;
@@ -272,6 +286,7 @@ abstract class CreateSubCommand extends Command<int> {
272286 'description' : projectDescription,
273287 if (this is OrgName ) 'org_name' : (this as OrgName ).orgName,
274288 if (this is Publishable ) 'publishable' : (this as Publishable ).publishable,
289+ if (this is Workspace ) 'workspace' : (this as Workspace ).workspace,
275290 };
276291 }
277292}
@@ -359,3 +374,12 @@ mixin Publishable on CreateSubCommand {
359374 fallbackValue: false ,
360375 );
361376}
377+
378+ /// Mixin for [CreateSubCommand] subclasses that receives the workspace flag.
379+ ///
380+ /// Takes care of parsing it from [argResults] and pass it
381+ /// to the brick generator.
382+ mixin Workspace on CreateSubCommand {
383+ /// Gets the workspace flag.
384+ bool get workspace => argResults['workspace' ] as bool ? ?? false ;
385+ }
0 commit comments