@@ -17,15 +17,19 @@ Sets the `Package.isDiscontinued` and `Package.replacedBy` properties.
1717''' ,
1818 options: {
1919 'package' : 'The package to be discontinued.' ,
20+ 'value' : 'The value to set (defaults to true).' ,
2021 'replaced-by' :
21- 'The Package.replacedBy field (if not set will be set to `null`).'
22+ 'The Package.replacedBy field (if not set will be set to `null`).' ,
2223 },
2324 invoke: (options) async {
2425 final package = options['package' ];
2526 InvalidInputException .check (
2627 package != null && package.isNotEmpty,
2728 '`package` must be given' ,
2829 );
30+ final value = options['value' ] ?? 'true' ;
31+ InvalidInputException .checkAnyOf (value, 'value' , ['true' , 'false' ]);
32+ final valueToSet = value == 'true' ;
2933
3034 final p = await packageBackend.lookupPackage (package! );
3135 if (p == null ) {
@@ -45,8 +49,8 @@ Sets the `Package.isDiscontinued` and `Package.replacedBy` properties.
4549 if (pkg == null ) {
4650 throw NotFoundException .resource (package);
4751 }
48- pkg.isDiscontinued = true ;
49- pkg.replacedBy = replacedBy;
52+ pkg.isDiscontinued = valueToSet ;
53+ pkg.replacedBy = valueToSet ? replacedBy : null ;
5054 pkg.updated = clock.now ().toUtc ();
5155 tx.insert (pkg);
5256 return pkg;
0 commit comments