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
384ded5b
Commit
384ded5b
authored
Sep 10, 2015
by
Ian Fischer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Begin refactoring API around CommandHandlers and using it consistently in subclasses.
Also applies autoreformatting to init.dart.
parent
f4ed42e5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
14 deletions
+18
-14
common.dart
packages/flutter_tools/lib/src/common.dart
+3
-1
init.dart
packages/flutter_tools/lib/src/init.dart
+15
-13
No files found.
packages/flutter_tools/lib/src/common.dart
View file @
384ded5b
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
import
'dart:async'
;
import
'package:args/args.dart'
;
import
'package:args/args.dart'
;
abstract
class
CommandHandler
{
abstract
class
CommandHandler
{
...
@@ -12,7 +14,7 @@ abstract class CommandHandler {
...
@@ -12,7 +14,7 @@ abstract class CommandHandler {
ArgParser
get
parser
;
ArgParser
get
parser
;
void
processArgResults
(
ArgResults
results
);
Future
<
int
>
processArgResults
(
ArgResults
results
);
void
printUsage
([
String
message
])
{
void
printUsage
([
String
message
])
{
if
(
message
!=
null
)
{
if
(
message
!=
null
)
{
...
...
packages/flutter_tools/lib/src/init.dart
View file @
384ded5b
...
@@ -22,20 +22,22 @@ class InitCommandHandler extends CommandHandler {
...
@@ -22,20 +22,22 @@ class InitCommandHandler extends CommandHandler {
parser
.
addFlag
(
'help'
,
parser
.
addFlag
(
'help'
,
abbr:
'h'
,
negatable:
false
,
help:
'Display this help message.'
);
abbr:
'h'
,
negatable:
false
,
help:
'Display this help message.'
);
parser
.
addOption
(
'out'
,
abbr:
'o'
,
help:
'The output directory.'
);
parser
.
addOption
(
'out'
,
abbr:
'o'
,
help:
'The output directory.'
);
parser
.
addFlag
(
'pub'
,
defaultsTo:
true
,
parser
.
addFlag
(
'pub'
,
defaultsTo:
true
,
help:
'Whether to run pub after the project has been created.'
);
help:
'Whether to run pub after the project has been created.'
);
return
parser
;
return
parser
;
}
}
Future
processArgResults
(
ArgResults
results
)
async
{
@override
Future
<
int
>
processArgResults
(
ArgResults
results
)
async
{
if
(
results
[
'help'
])
{
if
(
results
[
'help'
])
{
printUsage
();
printUsage
();
return
new
Future
.
value
()
;
return
0
;
}
}
if
(!
results
.
wasParsed
(
'out'
))
{
if
(!
results
.
wasParsed
(
'out'
))
{
printUsage
(
'No option specified for the output directory.'
);
printUsage
(
'No option specified for the output directory.'
);
return
new
Future
.
value
()
;
return
2
;
}
}
// TODO: Confirm overwrite of an existing directory with the user.
// TODO: Confirm overwrite of an existing directory with the user.
...
@@ -58,7 +60,8 @@ Or if the Sky APK is not already on your device, run:
...
@@ -58,7 +60,8 @@ Or if the Sky APK is not already on your device, run:
if
(
results
[
'pub'
])
{
if
(
results
[
'pub'
])
{
print
(
"Running pub get..."
);
print
(
"Running pub get..."
);
Process
process
=
await
Process
.
start
(
'pub'
,
[
'get'
],
workingDirectory:
out
.
path
);
Process
process
=
await
Process
.
start
(
'pub'
,
[
'get'
],
workingDirectory:
out
.
path
);
stdout
.
addStream
(
process
.
stdout
);
stdout
.
addStream
(
process
.
stdout
);
stderr
.
addStream
(
process
.
stderr
);
stderr
.
addStream
(
process
.
stderr
);
int
code
=
await
process
.
exitCode
;
int
code
=
await
process
.
exitCode
;
...
@@ -67,7 +70,9 @@ Or if the Sky APK is not already on your device, run:
...
@@ -67,7 +70,9 @@ Or if the Sky APK is not already on your device, run:
}
}
}
else
{
}
else
{
print
(
message
);
print
(
message
);
return
2
;
}
}
return
0
;
}
}
}
}
...
@@ -85,10 +90,7 @@ abstract class Template {
...
@@ -85,10 +90,7 @@ abstract class Template {
dir
.
createSync
(
recursive:
true
);
dir
.
createSync
(
recursive:
true
);
files
.
forEach
((
String
path
,
String
contents
)
{
files
.
forEach
((
String
path
,
String
contents
)
{
Map
m
=
{
Map
m
=
{
'projectName'
:
projectName
,
'description'
:
description
};
'projectName'
:
projectName
,
'description'
:
description
};
contents
=
mustache
.
render
(
contents
,
m
);
contents
=
mustache
.
render
(
contents
,
m
);
File
file
=
new
File
(
p
.
join
(
dir
.
path
,
path
));
File
file
=
new
File
(
p
.
join
(
dir
.
path
,
path
));
file
.
parent
.
createSync
();
file
.
parent
.
createSync
();
...
@@ -102,10 +104,10 @@ abstract class Template {
...
@@ -102,10 +104,10 @@ abstract class Template {
class
SkySimpleTemplate
extends
Template
{
class
SkySimpleTemplate
extends
Template
{
SkySimpleTemplate
()
:
super
(
'sky-simple'
,
'A minimal Sky project.'
)
{
SkySimpleTemplate
()
:
super
(
'sky-simple'
,
'A minimal Sky project.'
)
{
files
[
'.gitignore'
]=
_gitignore
;
files
[
'.gitignore'
]
=
_gitignore
;
files
[
'pubspec.yaml'
]=
_pubspec
;
files
[
'pubspec.yaml'
]
=
_pubspec
;
files
[
'README.md'
]=
_readme
;
files
[
'README.md'
]
=
_readme
;
files
[
'lib/main.dart'
]=
_libMain
;
files
[
'lib/main.dart'
]
=
_libMain
;
}
}
}
}
...
...
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