Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
785e557a
Unverified
Commit
785e557a
authored
Nov 21, 2019
by
Jonah Williams
Committed by
GitHub
Nov 21, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove Flags (#45320)
parent
1fae83cf
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
1 addition
and
166 deletions
+1
-166
flags.dart
packages/flutter_tools/lib/src/base/flags.dart
+0
-67
context_runner.dart
packages/flutter_tools/lib/src/context_runner.dart
+0
-2
flutter_command_runner.dart
.../flutter_tools/lib/src/runner/flutter_command_runner.dart
+1
-4
flags_test.dart
...ges/flutter_tools/test/general.shard/base/flags_test.dart
+0
-93
No files found.
packages/flutter_tools/lib/src/base/flags.dart
deleted
100644 → 0
View file @
1fae83cf
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:args/args.dart'
;
import
'context.dart'
;
/// command-line flags and options that were specified during the invocation of
/// the Flutter tool.
Flags
get
flags
=>
context
.
get
<
Flags
>();
/// Encapsulation of the command-line flags and options that were specified
/// during the invocation of the Flutter tool.
///
/// An instance of this class is set into the [AppContext] upon invocation of
/// the Flutter tool (immediately after the arguments have been parsed in
/// [FlutterCommandRunner]) and is available via the [flags] global property.
class
Flags
{
Flags
(
this
.
_globalResults
)
:
assert
(
_globalResults
!=
null
);
final
ArgResults
_globalResults
;
/// Gets the value of the specified command-line flag/option that was set
/// during the invocation of the Flutter tool.
///
/// This will first search for flags that are specific to the command and will
/// fall back to global flags.
///
/// If a flag has a default value and the user did not explicitly specify a
/// value on the command-line, this will return the default value.
///
/// If the specified flag is not defined or was not specified and had no
/// default, then this will return `null`.
dynamic
operator
[](
String
key
)
{
final
ArgResults
commandResults
=
_globalResults
.
command
;
final
Iterable
<
String
>
options
=
commandResults
?.
options
;
if
(
options
!=
null
&&
options
.
contains
(
key
))
{
return
commandResults
[
key
];
}
else
if
(
_globalResults
.
options
.
contains
(
key
))
{
return
_globalResults
[
key
];
}
return
null
;
}
/// `true` iff the given flag/option was either explicitly specified by the
/// user at the command-line or it was defined to have a default value.
bool
contains
(
String
key
)
{
final
ArgResults
commandResults
=
_globalResults
.
command
;
final
Iterable
<
String
>
options
=
commandResults
?.
options
;
return
(
options
!=
null
&&
options
.
contains
(
key
))
||
_globalResults
.
options
.
contains
(
key
);
}
}
class
EmptyFlags
implements
Flags
{
const
EmptyFlags
();
@override
ArgResults
get
_globalResults
=>
null
;
@override
String
operator
[](
String
key
)
=>
null
;
@override
bool
contains
(
String
key
)
=>
false
;
}
packages/flutter_tools/lib/src/context_runner.dart
View file @
785e557a
...
...
@@ -14,7 +14,6 @@ import 'asset.dart';
import
'base/build.dart'
;
import
'base/config.dart'
;
import
'base/context.dart'
;
import
'base/flags.dart'
;
import
'base/io.dart'
;
import
'base/logger.dart'
;
import
'base/os.dart'
;
...
...
@@ -88,7 +87,6 @@ Future<T> runInContext<T>(
DoctorValidatorsProvider:
()
=>
DoctorValidatorsProvider
.
defaultInstance
,
EmulatorManager:
()
=>
EmulatorManager
(),
FeatureFlags:
()
=>
const
FeatureFlags
(),
Flags:
()
=>
const
EmptyFlags
(),
FlutterVersion:
()
=>
FlutterVersion
(
const
SystemClock
()),
FuchsiaArtifacts:
()
=>
FuchsiaArtifacts
.
find
(),
FuchsiaDeviceTools:
()
=>
FuchsiaDeviceTools
(),
...
...
packages/flutter_tools/lib/src/runner/flutter_command_runner.dart
View file @
785e557a
...
...
@@ -15,7 +15,6 @@ import '../artifacts.dart';
import
'../base/common.dart'
;
import
'../base/context.dart'
;
import
'../base/file_system.dart'
;
import
'../base/flags.dart'
;
import
'../base/io.dart'
as
io
;
import
'../base/logger.dart'
;
import
'../base/os.dart'
;
...
...
@@ -253,9 +252,7 @@ class FlutterCommandRunner extends CommandRunner<void> {
@override
Future
<
void
>
runCommand
(
ArgResults
topLevelResults
)
async
{
final
Map
<
Type
,
dynamic
>
contextOverrides
=
<
Type
,
dynamic
>{
Flags:
Flags
(
topLevelResults
),
};
final
Map
<
Type
,
dynamic
>
contextOverrides
=
<
Type
,
dynamic
>{};
// Check for verbose.
if
(
topLevelResults
[
'verbose'
]
as
bool
)
{
...
...
packages/flutter_tools/test/general.shard/base/flags_test.dart
deleted
100644 → 0
View file @
1fae83cf
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:async'
;
import
'package:flutter_tools/src/base/flags.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/runner/flutter_command.dart'
;
import
'../../src/common.dart'
;
import
'../../src/context.dart'
;
typedef
_TestMethod
=
FutureOr
<
void
>
Function
();
void
main
(
)
{
Cache
.
disableLocking
();
Future
<
void
>
runCommand
(
Iterable
<
String
>
flags
,
_TestMethod
testMethod
)
async
{
final
List
<
String
>
args
=
<
String
>[
'test'
,
...
flags
];
final
_TestCommand
command
=
_TestCommand
(
testMethod
);
await
createTestCommandRunner
(
command
).
run
(
args
);
}
testUsingContext
(
'runCommand works as expected'
,
()
async
{
bool
testRan
=
false
;
await
runCommand
(<
String
>[],
()
{
testRan
=
true
;
});
expect
(
testRan
,
isTrue
);
});
group
(
'flags'
,
()
{
testUsingContext
(
'returns null for undefined flags'
,
()
async
{
await
runCommand
(<
String
>[],
()
{
expect
(
flags
[
'undefined-flag'
],
isNull
);
});
});
testUsingContext
(
'picks up default values'
,
()
async
{
await
runCommand
(<
String
>[],
()
{
expect
(
flags
[
'verbose'
],
isFalse
);
expect
(
flags
[
'flag-defaults-to-false'
],
isFalse
);
expect
(
flags
[
'flag-defaults-to-true'
],
isTrue
);
expect
(
flags
[
'option-defaults-to-foo'
],
'foo'
);
});
});
testUsingContext
(
'returns null for flags with no default values'
,
()
async
{
await
runCommand
(<
String
>[],
()
{
expect
(
flags
[
'device-id'
],
isNull
);
expect
(
flags
[
'option-no-default'
],
isNull
);
});
});
testUsingContext
(
'picks up explicit values'
,
()
async
{
await
runCommand
(<
String
>[
'--verbose'
,
'--flag-defaults-to-false'
,
'--option-no-default=explicit'
,
'--option-defaults-to-foo=qux'
,
],
()
{
expect
(
flags
[
'verbose'
],
isTrue
);
expect
(
flags
[
'flag-defaults-to-false'
],
isTrue
);
expect
(
flags
[
'option-no-default'
],
'explicit'
);
expect
(
flags
[
'option-defaults-to-foo'
],
'qux'
);
});
});
});
}
class
_TestCommand
extends
FlutterCommand
{
_TestCommand
(
this
.
testMethod
)
{
argParser
.
addFlag
(
'flag-defaults-to-false'
,
defaultsTo:
false
);
argParser
.
addFlag
(
'flag-defaults-to-true'
,
defaultsTo:
true
);
argParser
.
addOption
(
'option-no-default'
);
argParser
.
addOption
(
'option-defaults-to-foo'
,
defaultsTo:
'foo'
);
}
final
_TestMethod
testMethod
;
@override
String
get
name
=>
'test'
;
@override
String
get
description
=>
'runs a test method'
;
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
await
testMethod
();
return
null
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment