diff --git a/lib/src/command/add.dart b/lib/src/command/add.dart index 8282d2c40..5e098b213 100644 --- a/lib/src/command/add.dart +++ b/lib/src/command/add.dart @@ -88,6 +88,8 @@ For example: @override String get docUrl => 'https://dart.dev/tools/pub/cmd/pub-add'; + @override + bool get isOffline => argResults.flag('offline'); AddCommand() { argParser.addFlag( diff --git a/test/add/common/add_test.dart b/test/add/common/add_test.dart index 6cd2ccba2..645877bba 100644 --- a/test/add/common/add_test.dart +++ b/test/add/common/add_test.dart @@ -1148,4 +1148,14 @@ dependency_overrides: await pubAdd(args: ['foo'], output: contains('+ foo 1.0.0')); }); + + test('`--offline` works', () async { + final server = await servePackages(); + server.serve('foo', '1.0.0'); + await runPub(args: ['cache', 'add', 'foo', '--version', '1.0.0']); + + await d.appDir().create(); + server.serve('foo', '2.0.0'); + await pubAdd(args: ['foo', '--offline']); + }); }